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

.
Screamer

blackvj,
С ходу увидел. вместо $getImages надо 'getImages' в вызове функции.
Ну или перенеси функцию выше, только избавься от имени и присвой её переменной $getImages:

$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].'/1.gif" /><br/>';

}

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

Второй способ будет работать только если у тебя PHP5.3 и выше.