Просмотр поста

.
blackvj

Screamer,

$text = 'ФОТО [im]bonus[/im]';

$getImages = function ($matches) {
$array = array();
$dir = opendir('../'.$matches[1].'/');
while ($file = readdir($dir)) {
if (($file != '.') && ($file != "..")) {
$array[] = $file;
}
}
closedir($dir);
$total = count($array);
$end = $start + $kmess;
for ($i = $start; $i < $end; $i++) {

$t = '<img src="http://сайт.ru/'.$matches[1].'/' . $array[$i] . '.gif.gif" /><br/>';

}

return $t;
};
$text = preg_replace_callback('#\[im\](.*?)\[/im\]#si', 'getImages', $text);

echo $text;


Итог

ФОТО [im]bonus[/im]