Since PHP 5.4 it’s possible to do exactly that:
getSomeArray()[2]
Reference: https://secure.php.net/manual/en/language.types.array.php#example-62
On PHP 5.3 or earlier, you’ll need to use a temporary variable.
More Related Contents:
- Can't echo items from array
- Undefined Offset Array [closed]
- How to access and manipulate multi-dimensional array by key names / path?
- Is there a function to extract a ‘column’ from an array in PHP?
- How to solve PHP error ‘Notice: Array to string conversion in…’
- List of Big-O for PHP functions
- PHP: How to remove specific element from an array?
- recursive array_diff()?
- Is there a way to find out how “deep” a PHP array is?
- Passing an Array as Arguments, not an Array, in PHP
- PHP: Check if an array contains all array values from another array
- PHP Add element to every sub array of multi dimension array
- Best way to transfer an array between PHP and Javascript [duplicate]
- How to skip the 1st key in an array loop?
- PDO fetchAll array to one dimensional
- How to use php array with sql IN operator? [duplicate]
- How to access a property of an object (stdClass Object) member/element of an array? [duplicate]
- PHP curly braces in array notation
- Explode string into array with no empty elements?
- Group 2d array rows by one column and sum another column [duplicate]
- Iterating over a complex Associative Array in PHP
- Merging two arrays with the “+” (array union operator) How does it work?
- Interleaving multiple arrays into a single array
- Group 2d array data by one column and sum other columns in each group (separately)
- Easy way to apply a function to an array
- what is a good method to sanitize the whole $_POST array in php? [duplicate]
- foreach with three variables add
- Recursive array_search
- phpexcel Allowed memory size of 134217728 bytes exhausted [duplicate]
- Check if all values in array are the same