preg_replace
Posted: Sun Feb 27, 2005 5:26 pm
i build a very small parser. it reads a file and replaces some bb code into html and stuff like that. now i want to extend it so that it replaces patterns like for example with the contents of a file header.inc.php.
in started off with this line:
and thought, that
and the function insert did the right. problem: if i do an echo in the function, it echos for example "header", but if i use the line
it is trying to include "$1.inc.php" and not "header.inc.php" (where parameter is the parameter of the function insert()).
what am i doing wrong and what is the right solution?
btw: i read about preg_replace_callback, but didn't quite get the explanation in the manual. is that what i need?
Code: Select all
<!-- header -->in started off with this line:
Code: Select all
$content = preg_replace ("/\<\!\-\- (їa-z]*) \-\-\>/", "$1", $content);Code: Select all
$content = preg_replace ("/\<\!\-\- (їa-z]*) \-\-\>/", insert("$1"), $content);Code: Select all
include ($parameter . '.inc.php'what am i doing wrong and what is the right solution?
btw: i read about preg_replace_callback, but didn't quite get the explanation in the manual. is that what i need?