RE: [PHP] How do I do this PERL in PHP?
| From: | Chris Shiflett | Date: | Tue, 16 Sep 2003 18:13:42 +0000 |
| Subject: | RE: [PHP] How do I do this PERL in PHP? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-162772@lists.php.net to get a copy of this message | ||
--- Susan Ator <SAtor@npr.org> wrote:
> It works beautifully. My only question is there a way to pass a
> variable to the ereg? In other words:
>
> if( ereg( '^<TO>(.*)$', $line, $matches ) )
>
> would become:
>
> if( ereg( '^<$var>(.*)$', $line, $matches ) )
>
> I've tried doing eval but that was a no go.
That first argument is just a string, so you can generate it any way you want.
When you use single quotes, the string is considered to be literal text. Use
double quotes if you want $var to be evaluated.
Hope that helps.
Chris
=====
Become a better Web developer with the HTTP Developer's Handbook
http://httphandbook.org/