Re: array 2 links

From: Date: Fri, 04 May 2001 09:21:31 +0000
Subject: Re: array 2 links
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-51396@lists.php.net to get a copy of this message
Hi, You are really messed up with this 'if' statement. What you want is nicely described, so I won't repeat it, just make some correction... function array2links($cat, $arr) { $i = 0; $cat = rawurlencode($cat); while ( list( $key, $val ) = each($arr)) { $out .= "<a class=\"cats\" href=\"products.php?Cat=$cat&Code=$key\" title=\"$val\">$val</a><br>"; if ( $i == 5 ) { $out .= "</td><td valign=\"top\">"; $i = 1; } else $i++; } return $out; } ----- Original Message ----- From: "Joseph Blythe" <joe.blythe@binarylogic.com.au> To: <php-general@lists.php.net> Sent: 2001. május 4. 08:02 Subject: [PHP] array 2 links > 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. > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#51396) next »