Tags
PHP
Asked 3 years ago
20 Jul 2021
Views 263
Margaret

Margaret posted

How to convert an array into an object using stdClass()

i have very some array in my script but i want to convert to object for some reason but dont know how to convert array to object ? may be stdClass can be used for it
Mitul Dabhi

Mitul Dabhi
answered Jul 21 '21 00:00

cast array to object would be by stdClass

$array=array('test'=>'1');
$object=(stdClass) $array;


see above code in that (stdClass) will convert array to object easily
Post Answer