preg_replace with "eval"?
From: Sven (google_at_hofrichter.net)
Date: 10/20/04
- Previous message: Fu, Ren-Li: "problems using mysql_pconnect effectively"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 20 Oct 2004 05:10:09 -0700
Hi,
I tried to code a "one-line"-replacment-function, that put a found
value into a variable and deletes it from string. I know, it is
possible to do it by using a help-function (example 2), but I'm
looking for a "shorter" way.
$subject = "Re: PUT: an answered mail";
[example 1]
$subject = preg_replace(
"/^((Re|AW):\s*)/ie","\$isanswer='\$1'",$subject );
=> I wanted to get:
- $isanswer="Re: "
- $subject ="PUT: an answered mail"
=> but I got:
- $isanswer="Re: "
- $subject ="Re: PUT: an answered mail"
[example 2]
$subject = preg_replace(
"/^((Re|AW):\s*)/ie","setAnswer(\$1)",$subject );
function setAnswer( $val ) { \$isanswer='\$1'; return ""; }
-> I wanted to get and got it:
- $isanswer="Re: "
- $subject ="PUT: an answered mail"
Any ideas to filter it shorter (with an higher performance).
- Previous message: Fu, Ren-Li: "problems using mysql_pconnect effectively"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|