help
Posted: Thu Mar 25, 2010 2:58 am
Hi
I am new to regular expressions please help me in writing this function
Write a function in PHP that will take in 2 parameters: 1) a string of text 2) an array of words to be replaced where the key is the original word and the value is the new word. The function should return the corrected string.
i.e.
I am new to regular expressions please help me in writing this function
Write a function in PHP that will take in 2 parameters: 1) a string of text 2) an array of words to be replaced where the key is the original word and the value is the new word. The function should return the corrected string.
i.e.
Code: Select all
<?php
function cleanString($str, $wordArray) {
...
}
$wordArray = array('cat'=>'dog','bad'=>'good','old'=>'new');
echo cleanString($someString, $wordArray);
?>