php function smiles string dir glob pic smiles gif foreach dir as key

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
<?php
function smiles($string)
{
$dir = glob("pic/smiles/*.gif");
foreach($dir as $key => $value) {
$c = explode('.', $value);
$e = $c[1];
$f = $c[0];
$string = str_replace(":$f",'<img src="pic/smiles/'.$f.'.'.$e.'" alt="">', $string);
}
return $string;
}