0

Suppose i have function

array get_array($argument)


I want access to single element of this array in, so, python style like this:

$vector = get_array($argument)[2];

There is an elegant way to do this without new variables, rewriting function and so on?

1
  • Can you explain with example what you are trying to achieve? To get array inner element, you can use $myArray[$argument][2] Commented Sep 16, 2014 at 10:48

1 Answer 1

2

Sure, use PHP 5.4, which supports function array dereferencing

Function array dereferencing has been added, e.g. foo()[0].

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.