Answers for "array convert to object in php"

PHP
9

php convert array to object

$object = (object) $array;
Posted by: Guest on March-17-2020
0

php convert object to array

$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

array to object php

$object = json_decode(json_encode($array), FALSE);
Posted by: Guest on January-22-2021
1

convert array to object php

$arrayResult = array_map(function($array){
    return (object)$array;
}, $yourOrinalArray);
Posted by: Guest on July-17-2020

Code answers related to "array convert to object in php"

Browse Popular Code Answers by Language