if ($index = 0) {
continue;
}
store 0 value to $index
variable, what you want is if ($index == 0)
or, better if (!$index)
In php (and other languages I assume) you can set a variable data in a condition, this is often not what you want ans should be avoided, but sometimes can be useful, take this example:
$len = $query->count() // mysql query count()
if ($len) {
// do stuff
}
// this can be shortened to
if ($len = $query->count()) {
// do stuff if true
echo $len; // will echo the actual count()
}
to avoid errors like this, I usually test my variables like this:
if (0 == $index)
this WILL throw an error if you miss your expression not on purpose :) but nowadays, when using IDE like phpstorm, netbeans or others, generally there is an inspection that warn you about that statement.
EDIT:
Here the inspection to enaable in PHPStorm:

And here the result:
