traversing multidimensional arrays

awesome!

so i was getting the invalid foreach() because $i1337intel was returning null? or 0, and 0 is seen as false?

and overlooking the code i understand most of what i see, what i am not understanding is this line:
[php]
if(isset($numbera[$i+1]) && ($num*10 + ($numbera[$i+1])) <= 26)
[/php]
i understand what it does, just not how.

Sorry, I really should comment my code.

The foreach was invalid because the element it was choosing ($num-1) didn’t exist. Typically a foreach will fail if the variable chosen is either not set or isn’t an array.

isset($numbera[$i+1]) checks that there is a number that comes after the current one.

($num*10 + ($numbera[$i+1])) <= 26 takes the current number and multiplies it by ten. It then adds the next number in the given variable ($number in this case) which is defined by ($numbera[$i+1]). For example if the number was 1234, and the loop was currently at the beginning the current number would be 1. Times that by 10 and you get 10. Add the next number (2) and you get 12. It then checks that the value created by this is a valid value to be assigned to a letter.

Hopefully this clears things up?

yes it does thank you again.

Sponsor our Newsletter | Privacy Policy | Terms of Service