$string = ":abc and :def have apples.";
$replacements = array('Mary', 'Jane');
हो जाना चाहिए:preg_replace
Mary and Jane have apples.
अभी मैं इस तरह यह कर रहा हूँ:
preg_match_all('/:(\w+)/', $string, $matches);
foreach($matches[0] as $index => $match)
$string = str_replace($match, $replacements[$index], $string);
मैं एक ही समय में यह कर सकता, preg_replace की तरह कुछ का उपयोग कर ?
[यह] (http://codepad.org/KfP3g02m) कैसे आप एक साहचर्य सरणी के साथ यह कर सकते हैं है। – Teneff