[SOLVED] Filtering the output of an array
Posted: Fri Dec 16, 2005 10:11 pm
I've got an array output code that looks like this:
I want that to be able to take any words in the $band array and if they are found, replace them with ***.
If I change $band in the strpos() and str_repace() functions with a word in quotes, like "hello" it works, but using the array variable does not.
Could anyone tell me how I could achieve this goal?
Thanks!
Code: Select all
foreach ($Array as $key => $val) {
$band = array("bad","words","here");
if(strpos($val, $band) !== FALSE) {
$val = str_replace($band,"***",$val);
echo $val; }
else {
echo $val;
}
echo "<br />"; }If I change $band in the strpos() and str_repace() functions with a word in quotes, like "hello" it works, but using the array variable does not.
Could anyone tell me how I could achieve this goal?
Thanks!