The problem is this:
$i = 0;
while($i++){
When you do $i++
the variable $i
is incremented with one but the value that is returned is still the old value, see the manual on Incrementing/Decrementing operators. So the first time when $i
is still 0
, the condition evaluates to false
and the whole while()
loop is never run / your switch
is never reached.
To increase first and then return the value, you do:
$i = 0;
while(++$i){
See the example.