Код: Выделить всё
<?php
include ("connect.php");
function my()
{
global $template;
if (isset($template->_tpldata['postrow']))
{
// Применяем функцию do_replace() к каждому члену массива postrow, содержащего тексты сообщений
array_walk($template->_tpldata['postrow'], 'do_replace');
}
}
function dealers($brend,$city)
{
$sql_dealers = mysql_query("select * from ado where city='".$city."' and auto='".$brend."'");
$count_dealers = mysql_num_rows($sql_dealers);
for ($i=0;$i<$count_dealers;$i++)
{
$dealer = mysql_fetch_array($sql_dealers);
//$content.= iconv("windows-1251","utf-8",$dealer['name'])."<br>";
$content.= iconv("windows-1251","utf-8",$dealer['name'])."<br>";
}
return $content;
}
function do_replace(&$item)
{
// Составляем список знаков препинания
preg_match("/%brend=(.*) city=(.*)%/isU",$item['MESSAGE'],$result);
$content = dealers($result[1],$result[2]);
$item['MESSAGE'] = str_replace("%city=".$result[1]."%",$content,$item['MESSAGE']);
}
// Регистрируем хук
$phpbb_hook->register(array('template', 'display'), 'my');
?>%brend=Renault city=Воронеж% как было в посте так и осталось - замена не прошлав тоже время
$content = dealers($result[1],$result[2]); имеет нужное значение (проверено print спереди - все выводит)В чем проблема? Почему не проходит замена
%brend=Renault city=Воронеж% на текст из переменной $content = dealers($result[1],$result[2]); ?Хук должен заменять в постах конструкции типа
%brend=Renault city=Воронеж%

