Jump to content

Infinite Loop


Manixat

Recommended Posts

Because $i + 2 does not increment $i by 2. It only Adds $i and 2 and leaves the result on the stack. I.e. it doesn't do anything. Use $i += 2

$a = array("a","b","c","d","e","f");
$b = array();
for($i=0;$i<=count($a);$i+=2)
{
$b[$a[$i]] = $a[$i+1];
}
print_r($B);

Link to comment
https://forums.phpfreaks.com/topic/270808-infinite-loop/#findComment-1393094
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.