Modifier with preg_replace_callback

From: Date: Thu, 11 Mar 2004 16:16:23 +0000
Subject: Modifier with preg_replace_callback
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-11094@lists.php.net to get a copy of this message
Hello! I'm trying to obfuscate and "linkify" mail addresses in a text with the following modifier: function smarty_modifier_mail_escape($string) {
     return preg_replace_callback("/[_a-z0-9.A-Z]+@[-a-z0-9.A-Z]+/","escape_mail",$string);
} function escape_mail($text) {
     echo "escape_mail called";//<-- for debugging purposes, to test if the func is called
     $text=$text[0];
     for($i=0;$i<strlen($text);$i++)
     {
         $mailto.="&#".ord($text[$i]).";";
     }
     return "<a href=\"&#109;&#97;&#105;&#108;&#116;&#111;&#58;$mailto\">$mailto</a>";
} The two functions are in the same file but escape_mail doesn't get called (Smarty 2.3, PHP 4.1). What am I doing wrong? Is there another way to accomplish the obfuscation of email adresses that are mingled with normal text? With best regards Gabriel Birke -- KONTOR4_Neue Medien Plathnerstraße 5 30175 Hannover Fax: +49 51184 48 98 99 mailto:birke@kontor4.de http://www.kontor4.de

« previous php.smarty.general (#11094) next »