domingo, 10 de noviembre de 2019

object to array

217
The easiest way is to JSON-encode your object and then decode it back to an array:
$array = json_decode(json_encode($object), True);
Or if you prefer, you can traverse the object manually, too:
foreach ($object as $value) 
    $array[] = $value->post_id
$info=json_decode($reply);
$array = json_decode(json_encode($info), True);

//print_r($array);
foreach($array['result'] as $key=>$value) {
echo " $key : $value<br>";
}



No hay comentarios:

Publicar un comentario