note 22940 added to function.key
| From: | kajetan at kajetan dot nu | Date: | Thu, 04 Jul 2002 17:20:06 +0000 |
| Subject: | note 22940 added to function.key | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-32595@lists.php.net to get a copy of this message | ||
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:
$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 ' ';
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.
--
http://www.php.net/manual/en/function.key.php
http://master.php.net/manage/user-notes.php?action=edit+22940
http://master.php.net/manage/user-notes.php?action=delete+22940
http://master.php.net/manage/user-notes.php?action=reject+22940