any idea how if the following is possible in PHP as a single line ?:
<?php $firstElement = functionThatReturnsAnArray()[0];
… It doesn’t seem to ‘take’. I need to do this as a 2-stepper:
<?php $allElements = functionThatReturnsAnArray(); $firstElement = $allElements[0];
… just curious – other languages I play with allow things like this, and I’m lazy enoug to miss this in PHP … any insight appreciated …
Try:
If you’re just looking for the first element of the array.