The Way to Programming
The Way to Programming
i’ve problem with PHP. i want learning PHP and i read books, watching tutorials and i wrote this code by myself;
why this code not working ? please help me.
you should use foreach to loop over arrays, however, to answer your question as to why your code isn’t working:
In PHP the integer 0 is falsy, the first element in your array is 0 so the while loop never executes (because the first condition is false), you would need to do a type-sensitive comparison to use while:
while (($a = current($num)) !== false) { ... }
Definitely use foreach though.
Sign in to your account