array 2 links

From: Date: Fri, 04 May 2001 06:02:41 +0000
Subject: array 2 links
Groups: php.general 
Request: Send a blank email to php-general+get-51371@lists.php.net to get a copy of this message
Hello, I seem to be having some difficulty understanding why the following function skips every 5th array item, basically the following function takes two parameters category and an array, when placed inside a table it will generate links based on the array items splitting the table into columns when more than 4 links have been generated. However as mentioned every 5th array item is skipped hmm.. The solution is probably really obvious but I can't seem to see it! function array2links($cat, $arr) { $i = 0; $cat = rawurlencode($cat); while ( list( $key, $val ) = each($arr)) { $link = "<a class=\"cats\" href=\"products.php?Cat=$cat&Code=$key\" title=\"$val\">$val</a><br>"; if ( $i < 4 ) { $out .= "$link"; } else { $out .= "</td><td valign=\"top\">"; $i = 0; continue; } $i++; } return $out; } Any help/ideas would be appreciated, Regards, Joseph.

« previous php.general (#51371) next »