Re: running a function on an eregi-substring
| From: | Ernest E Vogelsinger | Date: | Mon, 19 May 2003 13:16:19 +0000 |
| Subject: | Re: running a function on an eregi-substring | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-148159@lists.php.net to get a copy of this message | ||
At 12:53 19.05.2003, Michiel van Heusden said:
--------------------[snip]--------------------
>i'm having trouble using eregi_replace in a script similar to the following
>don't if this is possible at all but i'd like to know if this is possible,
>how to fix it, any help?
>
><?
>
>$content = "hello world";
>
>function makebold ($string) {
> return "<b>" . $string . "</b>";
>}
>
>$output = eregi_replace("hello", makebold(\\0), $content);
>
>echo $output;
--------------------[snip]--------------------
To make group references work you need to use group parentheses in the
pattern string:
$output = eregi_replace("(hello)", makebold(\\0), $content);
Now this will work as expected.
--
>O Ernest E. Vogelsinger
(\) ICQ #13394035
^ http://www.vogelsinger.at/