note 22940 deleted from function.key by peehaa

From: Date: Mon, 08 Jul 2013 21:00:14 +0000
Subject: note 22940 deleted from function.key by peehaa
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-195535@lists.php.net to get a copy of this message
Note Submitter: kajetan at kajetan dot nu ---- I'm writing a forum and use an array to hold all the smiles. The keys in the array are the characters to write to get a smiley, and the data is the filename, like this $Smiles[':-)'] = 'smile.gif' To output all the smileys in a table with 3 columns, I wrote this code: <?php $the_end = false; $s = reset($Smiles); $k = key($Smiles); while(!$the_end){ echo '<tr>'; for($i=0; $i<3; $i++){ echo '<td>'; if($the_end) echo '&nbsp;'; else{ echo $k.'< br><img src="'. $s .'">'; $s = next($Smiles); if ($s==false) $the_end=true; else $k = key($Smiles); } echo "</td>\n"; } echo "</tr>\n"; } ?> I had to write a space in the < br> tag in the code above, because the board did a line brake otherwise.

« previous php.notes (#195535) next »