Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access PHP array element with a function?

Tags:

I'm working on a program that uses PHP's internal array pointers to iterate along a multidimensional array. I need to get an element from the current row, and I've been doing it like so:

$arr[key($arr)]['item']

However, I'd much prefer to use something like:

current($arr)['item'] // invalid syntax

I'm hoping there's a function out there that I've missed in my scan of the documentation that would enable me to access the element like so:

getvalue(current($arr), 'item')

or

current($arr)->getvalue('item')

Any suggestions?