interclubs
asked on
Search and Replace Function...
I have an array like such:
$ReplaceTerms = array(
'dog' => 'cat',
'fire' => 'water'
);
and I am looking to put together a function that I can pass the array and content to like such:
TransformInput($ReplaceTer ms, $content)
The Function would then do a case insensitive search and replace on $content swapping out the text in the array. So 'dog' would become 'cat' and 'fire' would become 'water'
Make any sense?
$ReplaceTerms = array(
'dog' => 'cat',
'fire' => 'water'
);
and I am looking to put together a function that I can pass the array and content to like such:
TransformInput($ReplaceTer
The Function would then do a case insensitive search and replace on $content swapping out the text in the array. So 'dog' would become 'cat' and 'fire' would become 'water'
Make any sense?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I'm sorry, my bad, the 2nd piece pass to it ($subjectarray) won't be an array, it will be just straight text...
as in : $testarr='foo dog fire foo dog';
as in : $testarr='foo dog fire foo dog';
Then you should be OK with the function I posted above. It tested out OK. Best, ~Ray
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Thanks for the question and the points.
if($val==$term){
to:
if($val===$term){