how to display an object in an array php? -


i'm trying display object stored in array can't work here have (that's var_dump shows me)

array(5) { [0]=> string(10) "04/06/2015" [1]=> string(1) "2" [2]=> string(1) "7" [3]=> string(1) "2" [4]=> object(stdclass)#64 (1) { ["esp_name"]=> string(11) "something" } }  array(5) { [0]=> string(10) "03/06/2015" [1]=> string(1) "1" [2]=> string(1) "7" [3]=> string(1) "3" [4]=> object(stdclass)#64 (1) { ["esp_name"]=> string(11) "something else" }}  

and i've managed display first 4 items can't display 1 in object

<?php   foreach ($resulba $i => $valor) { echo $valor[$i][0]; echo $valor[$i][1]; echo $valor[$i][2]; echo $valor[$i][3]; echo $valor???; } ?> 

using json_decode($jsonstring, true) last parameter set true not add stdclass objects data, arrays textual keys. should make accessing data easier.

failing anticipate source of data json, access object simple:

echo $valor[$i][4]; // object - cannot printed                     // first part used object access. echo $valor[$i][4]->esp_name; // property of object, string                     // properties of objects accessed "->" , property name. 

Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -