0
我想用一個數字替換給定字符串的每個實例。PHP:帶唯一替換的preg_replace
例如:
<?php
$string = "Hello Foo Text Apple"
preg_replace($pattern, $pattern.$i++, $string);
//output
Hello0 Foo1 Text2 Apple3
?>
的$模式是一個正則表達式查詢,但是在這種情況下,我已經使用純文本
你想替換或附加數字? – jwerre 2011-01-29 17:20:49
@jwerre:我想追加一個數字/字符串 – Zebra 2011-01-29 17:31:15