I just can't get this array to play nice. I'm using Laravel 4.2 and am throwing: ErrorException (E_UNKNOWN) Undefined offset: 1
$tags = Test\Zero::get_tags();
dd ($tags);
array (size=2)
0 =>
array (size=4)
'guid' => string '-a035-4742-bb65-c44' (length=36)
'name' => string 'tagtest1' (length=9)
'updateSequenceNum' => int 14
'parentGuid' => null
1 =>
array (size=4)
'guid' => string '-905e-466e-9e91-33ddggg4' (length=36)
'name' => string 'testtag2' (length=11)
'updateSequenceNum' => int 19
'parentGuid' => null
$tags = array_dot(`$tags);
array (size=8)
'0.guid' => string '-a035-4742-bb65-c44' (length=36)
'0.name' => string 'tagtest1' (length=9)
'0.updateSequenceNum' => int 14
'0.parentGuid' => null
'1.guid' => string '-905e-466e-9e91-33ddggg4' (length=36)
'1.name' => string 'testtag2' (length=11)
'1.updateSequenceNum' => int 19
'1.parentGuid' => null
$name = array_fetch($tags, '1.name');
echo $name;
How can I loop through to display all values with key 'name' ? Everything I try gives ErrorException (E_UNKNOWN) Undefined offset:
Any help would be greatly appreciated.
foreach ($tags as $tag) { echo $tag['name']; }will do - if you have PHP5.5, you can also use$names = array_column($tags, 'name');to retrieve an array of all the names us1.php.net/manual/en/function.array-column.php Is that what you are looking for?