Forum Moderators: coopster
example: (longhand I am trying to avoid)
$fruits=array("apples","pears","oranges","bananas");
$fruitSelection=1;
echo $fruits[$fruitSelection];
is there some way to do a shorthand like this?
echo array("apples","pears","oranges","bananas")[1]; Thanks for any help!
hehe. Sorry, couldn't resist.
To the best of my knowledge, no, well, not without jumping through hoops first. The point I am making here is that you already know which one you want, why go through the necessary steps to build the array? OK, I guess you could argue that it is all dynamic...Well, here is one example of jumping through the hoops
echo (array_pop(array_slice(array("apples","pears","oranges","bananas"), 1, 1)));