I always loved how i can quickly do with JavaScript:
function hello(){
return ['foo', 'bar'];
}
hello()[0]; // foo
Why can’t we do such things with PHP or is there another short syntax for that?
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.
No, it’s just plain not possible to access unnamed array or string by index in php.