Say I have a function that returns an array like this…
array(
0 => 'jpg',
1 => 400,
2 => 500
);
I want the indexes 1 and 2 only, and I want them as local variables. I don’t care about 0.
I could do…
list($throwaway, $width, $height) = getImageDetails($imagePath);
unset($throwaway);
…but obviously that is very ugly.
I tried placing NULL there, but I got the scope resolution error.
Is there a clean way to skip an array index using PHP’s list()?
Yep, don’t populate that argument, this is perfectly valid:
(see also Example 1 in the manual)