In this shortened example:
print_r($foo);
Array
(
[0] => Array
(
[function] => exception_handler
[class] => LP
[type] => ::
[args] => Array
(
[0] => Exception Object
(
[trace:Exception:private] => Array
(
[0] => Array
(
[args] => Array
(
[0] => 'hello'
[1] => 'world'
)
)
)
)
)
)
)
How do I access the last item which is "hello".
I am lost after $foo[0]['args'][0]
[0] => Exception Object
(
[trace:Exception:private] => Array
(
[0] => Array
(
[args] => Array
(
[0] => 'hello'
[1] => 'world'
)
)
)
)
It's an object of type Exception
and the values are within a (private
) property named trace
, thus I guess it's Exception::getTrace()
$trace = $foo[0]['args'][0]->getTrace();
echo end($trace[0]['args']);
... Just realize: You said "last item", but also you said "hello", so know I don't know, what you want. However, $trace[0]['args']
is a regular array and you should be able do with it, whatever you like :) end()
gives you the last item.
You can access it like this with PHP 5.4:
// Only works with PHP 5.4
$foo[0]['args'][0]->getTrace()[0]['args'][0];