Answers for "convert stdclass object to array"

PHP
0

convert stdclass object to array php

$person = new stdClass();
$person->firstName = "Taylor";
$person->age = 32;

//Convert Single-Dimention Object to array
$personArray = (array) $person;

//Convert Multi-Dimentional Object to Array
$personArray = objectToArray($person);
function objectToArray ($object) {
    if(!is_object($object) && !is_array($object)){
    	return $object;
    }
    return array_map('objectToArray', (array) $object);
}
Posted by: Guest on November-03-2019
0

stdclass to array

$stdClass = json_decode(json_encode($booking));
$array = json_decode(json_encode($booking), true);
Posted by: Guest on April-22-2021
0

Turning a StdClass object into an array

$array = get_object_vars( $obj );
Posted by: Guest on July-13-2021

Code answers related to "convert stdclass object to array"

Browse Popular Code Answers by Language