I need to get the last 6 values from a multi-dimensional array, I was trying to do something like this
{$ stats = array_shift ($ stats); }
But then after the first array_shift, I receive the following error
PHP Warning: array_shift (): Argument must be an array
< / Pre>Is there any work that can be done in PHP?
You can use:
$ stats = array_slice ( $ Figures, -6);
The reason for this is that your code is not working because
- draws from the front of the array - so that you remove the first 6, which The last 6 is not the same as receiving, as long as your array does not have 12 items ...
- The array_shift edits the array in place and removes the item
No comments:
Post a Comment