it looks pretty easy really using str_replace in php, all it does is search a text string for all or a number of instances of the text or character that you want to replace and then replaces it with the text you specified.
basic usage:
str_replace ( text_search_for, text_to_replace_with, the_string_applied_to )
example:
$moo = str_replace("moo", "cow", "lick me in the moo");
echo $moo;
will output lick me in the cow
you can also pass a count number, to get a count of the amount of times the search string is found
$moo = str_replace("moo", "cow", "lick me in the moo",$numb);
echo $numb;
will echo 0 (hopefully)
For further reading on this function here is a link to the full manual of str_replace().





kruxor on March 5th, 2010
Post Tags