I have the following code which unnecessarily takes up 2 lines:
<?php
$items = get_my_items();
$item4 = $items[4];
// get_my_items()[4] # invalid code
?>
I’m not a beginner but this small thing is nerving whole the time… Any suggestions?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It’s called array dereferencing. And it’s available as of PHP 5.4. If you want it, upgrade your PHP.