Quote:
Originally Posted by Troydere
Allow me to de-structure your function
PHP код:
function
{
loop start
{
check if car id is a cop car (loop number 1)
{
if so , stop the loop and the function itself and return 1;
}
if not
stop the loop and the function itself and return 0;
}
return 1; although you wont reach here anyway
}
And that's what would happen in run-time, you have a loop although it will run only once, completely killing the purpose of the loop.
You can solve this by changing the value of the last return to 0, and removing the else statement and its contents. It'd look like this
PHP код:
function
{
loop
{
check if the car is a cop car
{
if so, return 1;
}
}
if the loop above did not find any car, it did not stop the function, hence this return 0; will pass
}
|
Ohhhh, now i get it , i was thiking i need that else there so it will return 0 but i was wrong , i don't know if you return 1 there will finish the loop and return 1 ..... Now it's clear why it was not worked