https://blog.kovah.de/en/394a1-convert-arrays-objects-various-ways/ Examples for converting arrays into objects in PHP Kevin Woblick

Convert arrays to objects in various ways

TIL: You can convert arrays to objects in various ways:

$obj = (object) $array;
$obj = json_decode(json_encode($array));
$object = new stdClass();
foreach ($array as $key => $value) {
    $object->$key = $value;
}

This Blog happily accepts Webmentions

0 Mentions
0 Reposts
Likes