22 February 2013,
 0

I’ve been looking at a very strange issue for two hours now. I have an array with keys that begin with 101 and increment. The array is used to build a list of form menus and the same array is then used in the processing of saving the submission. The form input list is complete, specifically the ['101'] key holds a menu and that menu is on the screen so that part is fine. On submission however a var_dump shows that the loop begins at 102. $_POST shows that 101 is set which has no effect on looping through the array anyway.

So I decided to move ['101'] to the end of my array, change the key to 126 which is the next value and this means the array keys being with 102. I considered that for some strange reason the first key in the array is being skipped but to my surprised 102 is included in the loop after the form is submitted and 126 is also included. Nothing about this makes any sense so I thought I would post and hopefully someone can make me that little bit smarter by filling me in on why PHP is doing this!

Leave a Reply