php convert array to object
$object = (object) $array;
php convert array to object
$object = (object) $array;
convert array to object php
$arrayResult = array_map(function($array){
return (object)$array;
}, $yourOrinalArray);
convert array to object in php example
<?php
function toObject($arr) {
if (is_array($arr)) {
// Return object
return (object) array_map('toObject', $arr);
}
return false;
}
$empInfo = array(
'name'=>'John',
'address'=>'Houston',
'employment' => array
(
'id' => '1',
'address' => 'Los Angeles'
)
);
print_r(toObject($empInfo));
/*_____output_______*/
// OUTPUT
/*stdClass Object
(
[name] => John
[address] => Houston
[employment] => stdClass Object
(
[id] => 1
[address] => Los Angeles
)
)*/
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us