Reputation: 259
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
Upvotes: 0
Views: 255
Reputation: 21
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
}
?>
Upvotes: 2