note 54205 added to function.preg-replace-callback
| From: | admin at the-php-tree dot com | Date: | Mon, 27 Jun 2005 11:15:18 +0000 |
| Subject: | note 54205 added to function.preg-replace-callback | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-91011@lists.php.net to get a copy of this message | ||
Instead of using preg_replace_callback() you could use preg_replace() like below:
<?php
// ** Simple function: **
function my_function( $my_param_one, $my_param_two ) {
// ...
}
preg_replace( "! \{(.+)-(.+)\} !e", "my_function('\\1',
'\\2')", $input_string );
// ** Class: **
class my_class {
function my_class() {
preg_replace( "! \{(.+)-(.+)\} !e",
"\$this->my_function('\\1', '\\2')", $input_string );
}
function my_function( $my_param_one, $my_param_two ) {
// ...
}
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.preg-replace-callback.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+54205
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54205&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54205&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54205&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54205&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54205&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54205&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+54205&report=yes
Search -- http://master.php.net/manage/user-notes.php