PHP7 replace preg_replace() with preg_replace_callback()

You already have a topic for this, don"t create more for it.

The topic has a Solution, so no one will give me feedback for new problem.

The new problem involves giving you working code, which this and most forums don’t do.

It was spelled out what to do, you just have to implement it.

1 Like

any news about this error?

$johnny_left_teat .= preg_replace($find, $repl, $tpl);

Who can text with no contex/data?

Is this the same error as above?/ What error are you getting? (sigh)

I managed to solve this error!

////////////////////////////////////////////////////////
// Function: category_get_tree ALTERADO PHP7
function category_get_tree($prefix = ‘’, $tpl = ‘’, $no_prefix = true, $id = 0, $level = 0){
global $sql, $PHP_SELF;
static $johnny_left_teat;
$level++;
foreach ($sql->select(array(‘table’ => ‘categories’, ‘where’ => array(“parent = $id”), ‘orderby’ => array(‘ord’, ‘ASC’))) as $row){

  $find = ['/{(id|name|url|icon|template|prefix)}/', '/\[php\](.*?)\[\/php\]/'];

  $repl = [$row['id'], $row['name'], $row['url'], $row['icon'], $row['template'], $row['template'], ($row['parent'] or !$no_prefix), $prefix];

  $pref = $no_prefix ? $row['level'] : ($row['level'] + 1);
  $pref = $minus ? ($pref - (!$no_prefix ? ($minus - 1) : ($minus - 1))) : $pref;
  $pref = str_repeat($prefix, $pref);
  $row['prefix'] = $pref;

  $johnny_left_teat .= preg_replace_callback($find, function($m) use ($row) {
		return isset($row[$m[1]]) ? $row[$m[1]] : eval('return ' .$m[1]. ';');
	}, $tpl);
  
  category_get_tree($prefix, $tpl, $no_prefix, $row['id'], $level);

}
return $johnny_left_teat;
}

Sponsor our Newsletter | Privacy Policy | Terms of Service