I think every PHP coders have come across Arrays and stdClass Objects. Sometimes it’s very useful convert Objects to Arrays and Arrays to Objects. This is easy arrays to objects converting.
Here we are converting Objects to Arrays.
$obj = new stdClass(); $obj->key1 ='Value1'; $obj->key2 ='Value3'; $obj->key3 ='Value3'; $obj->key4 ='Value4'; $array = (Array)$obj; print_r($array); //Array ( [key1] => Value1 [key2] => Value3 [key3] => Value3 [key4] => Value4 )