简体   繁体   中英

Json decode delete stdClass

I have a json element, I decode it with the function json_decode($vr) but like result, it show me this

   Array( [0] => stdClass Object ( [id] => 4 [name] => Elis ) 
           [1] => stdClass Object ( [id] => 5 [name] => Eilbert ))1

with that array i can't do nothing, before i have to delete stdClass Object how can i do that? if i user json_encode($vr,true) I'll receive Array instead stdClass.

when i try do the foreach with the json econde it show me a error Object of class stdClass could not be converted to string, I thought that is for that stdClass

I imagine you need something like that:

<?php
foreach($array as $object){

$id = $object->id;
$name=$object->name;

echo "Hello $name your id is $id"; //Or whatever you want to do with it
}

?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM