Skip to content
Advertisement

Trimming off the not needed last x array indexes from an auto generated array

Code i’m currently using to generate the array..

JavaScript

and it very nicely produces arrays like so..

JavaScript

The arrays can have more or fewer items than my example but they always have at least 1 (sometimes 2) un-needed indexes at the end (like items [stuff] & [stuff2] in my example array.

Is there a way i can specify a value to hide the last x number of indexes?

Advertisement

Answer

Using array_pop($arr); I was able to solve my issue and when I want to remove more than 1 from the end I can repeat the code for each 1 want to chop off the end.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement