Re: Can I use a function within an ereg_replace?

From: Date: Tue, 03 Apr 2001 18:27:10 +0000
Subject: Re: Can I use a function within an ereg_replace?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-46861@lists.php.net to get a copy of this message
On 4/3/01 11:06 AM, "Dan Wilson" <dan@acucore.com> wrote: > Hey all, > > I'm trying to mangle email addresses to pass to an email sending form and > want to use a custom hashing function within an eregi_replace. > > Example: > > $text = eregi_replace("[my big email regex]", "send.php?addr=" . > hash_func("\\1@\\2.\\3"), $text); > > I can't seem to get this to work... it is just hashing the static text > within the function, not the replaced values. > > Can this just not be done? > > -Dan > If you set the value of a temporary variable to the result of hash_func(), does it return what you expect? If so, do that before the eregi_replace, add "send.php?addr=" to the beginning, and pass the temp var to eregi_replace. I know, it's a whole extra line of code, but at least you can test and make sure hash_func() is doing the right thing. Maybe you could try enclosing "send.php?addr=" . hash_func("\\1@\\2.\\3") In another set of () to enforce operator precedence? Ie. ( "send.php?addr=" . hash_func("\\1@\\2.\\3")) Just a thought.

« previous php.general (#46861) next »