note 77440 rejected from function.ereg-replace by cece
| From: | cece@php.net | Date: | Fri, 31 Aug 2007 12:02:28 +0000 |
| Subject: | note 77440 rejected from function.ereg-replace by cece | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-129939@lists.php.net to get a copy of this message | ||
Note Submitter: mbotta78 at hotmail dot com
----
is it posible to apply user defined function to replacement?
as sample this works for me:
echo ereg_replace('#([0-9]+)#', '<b>\\1<b>' ,
'string_received44');
but i would like to do something like:
echo ereg_replace('#([0-9]+)#', my_function('\\1') ,
'string_received44');
function my_function($input){
// this is just sample code,
// this function could be more complex
return 2 * $input;
}