![]() |
|
|
+ Search |
![]()
|
Dec 1st, 2003 12:41
Jakub Vrana, Dalton Hunter,
Take a look at function preg_replace_callback().
<?php
function add_numbers($matches) {
static $i = 0;
$i++;
return $matches[0] . $i;
}
echo preg_replace_callback("/cat/", "add_numbers", "a cat b cat c
cat");
// prints: a cat1 b cat2 c cat3
?>