Reputation: 417
I've got an array of arrays they have a different value.
i want to print [name]
field values of array ...
every time i use foreach my result not good...!
Array
(
[und] => Array
(
[0] => Array
(
[tid] => 5683
[taxonomy_term] => stdClass Object
(
[tid] => 5683
[name] => deded
)
)
[1] => Array
(
[tid] => 15143
[taxonomy_term] => stdClass Object
(
[tid] => 15143
[name] => dedeededswswsw
)
)
)
)
my code :
$array= ($array['und']);
foreach($array as $newarray){
print_r ($newarray);
}
thanks for your helps
Upvotes: 0
Views: 46
Reputation: 57131
You will notice that the output has more levels before you get to the name
field. If you follow the structure
Array
(
[tid] => 5683
[taxonomy_term] => stdClass Object
(
[tid] => 5683
[name] => deded
)
)
you would need to output...
foreach($array as $newarray){
echo $newarray['taxonomy_term']->name.PHP_EOL;
}
Upvotes: 1