Hi. According to the manual page for str_replace, all the parameters for str_replace can name be arrays, as detailed here:
http://www.php.net/manual/en/function.str-replace.php
The phpbuilder manual seems to be out of date, btw.
I am trying to use this function to strip some 'junk' words out of sentences. I have ab array of words such as 'of', 'and', 'the' etc. that i want to remove. In accordence with the new functionality of str_replace, here is my code:
<?php
// Load stop words array. This contains words such as to, as, a, for, it, the...
$StopWords=file("stopwords.inc");
// Set sample strings.
$strings[0]="to view cool forums, go to the-group.org";
$strings[1]="there's a bunch of cool forums at the-group.org";
$strings[2]="want to see some fun forums? go to the-group.org!";
// replace the stopwords with a blank string
$strings=str_replace($StopWords, "", $strings);
// echo the strings.
while(list($Key, $str)=each($strings)){
echo "\$strings[$Key]=\"$str\"<br>";
}
?>
This however, does not work. it outputs the following:
$strings[0]="to view cool forums, go to the-group.org"
$strings[1]="there's a bunch of cool forums at the-group.org"
$strings[2]="want to see some fun forums? go to the-group.org!"
any ideas?