Get the value of the returned array

How can I write this code in one php statement?

$menu = theme('nice_menu', 1, 10, 'down');
print $menu['content'];

Something like that:

print theme('nice_menu', 1, 10, 'down')['content'];
+3
source share
2 answers

Not on a production version of PHP. This is added to the trunk for the next version (currently called 5.3.99DEV, but she doesn’t know if it will be 5.4 or 6.0 or what) ... This is called Array dereferencing. See RFP ...

+2
source

This, unfortunately, is not possible (in the current state of PHP). Your first example is a way to do this.

0
source

Source: https://habr.com/ru/post/1759926/


All Articles