WHY do PHP reindex arrays and add integer indexes? |
ALL PHP ARRAYS are associative arrays.
So your simple single dimensional array of : PHP Code: $myArray = ['apple', 'banana', 'cherry']; is structurally the same as: PHP Code: $yourArray = [0 => 'apple', 1 => 'banana', 2 => 'cherry']; So, if you will using foreach like this: PHP Code: foreach ($myArray as $index => $value) That's simply how PHP internals work. If you ask why is that, then you need to ask the PHP maintainers themselves. |
Messages In This Thread |
WHY do PHP reindex arrays and add integer indexes? - by blaasvaer - 12-17-2020, 08:07 AM
RE: WHY do PHP reindex arrays and add integer indexes? - by paulbalandan - 12-17-2020, 08:37 AM
RE: WHY do PHP reindex arrays and add integer indexes? - by blaasvaer - 12-17-2020, 08:40 AM
RE: WHY do PHP reindex arrays and add integer indexes? - by includebeer - 12-21-2020, 05:47 AM
RE: WHY do PHP reindex arrays and add integer indexes? - by blaasvaer - 12-21-2020, 06:44 AM
|