Heyo, I'm a little stuck on this array, any help would be appreciated.
Here's the deal, this first takes all images in my emoticons directory and turns smile.gif into two things
$oldval (or "smile.gif")
and
$val (or "smile")
The next part, I'd like to use the commented out echo "':$val:' => '$oldval'),"; instead of hard coding the :triggername: and the image file names. within the loop, but it doesn't work for some reason. Any suggestions? Thanks!
-Sys
<?php
$contents = "hey :smile:";
$path = ($includes . "/emoticons");
$dir = dir($path);
while ($file = $dir->read()) {
if ((($file != ".") | ($file != "..")) && (!is_dir($file))) {
$filelist[] = $file;
}
}
asort($filelist);
while (list ($key, $val) = each ($filelist)) {
$oldval = $val;
$val = basename($val, ".gif") ;
$val = basename($val, ".png") ;
$val = basename($val, ".jpg") ;
//echo "':$val:' => '$oldval'),";
}
$smileys = array(
':smile:' => 'smile.gif',
':wink:' => 'wink.gif');
foreach($smileys as $smiley=>$image) {
$contents = str_replace($smiley, '<img src="/includes/emoticons/'.$image.'">', $contents); }
?>