-
☆ A M B ☆
- 24,524 Posts
Ah, sorry about that $modx->documentOutput line, I was playing around with it and accidentally left that there. The $source variable will work just as well.
The str_replace versus ereg_replace is just a matter of using the most efficient code. If you aren’t using any regular expressions in the replacement, str_replace is much more efficient.
Thank you Sottwell. So the problem was in line 203 ?!
What is exactly a "regular expression" ?
-
☆ A M B ☆
- 24,524 Posts
$search_content = '/[^|]('.$start_tag.')(.+?)('.$end_tag.')/sim';
preg_match($search_content, $source, $actual_source);
$content = $actual_source[0];
Here preg_match (related to ereg) (ereg_replace or preg_replace does replacing) is used properly. The $search_content definition contains a regular expression
/[^|]('.$start_tag.')(.+?)('.$end_tag.')/sim
It’s a code for exactly what to search for. All those symbols mean something in a regular expression. Learning how to use them is a whole project in itself. Then there are the native PHP regular expressions (ereg_whatever) and perl-style regular expressions (preg_whatever), so it gets real complicated.
http://il.php.net/ereg
http://il.php.net/manual/en/reference.pcre.pattern.syntax.php