how can you filter out values and print them in another array?

As @u_mulder said, you should store the result in another array.

You can also use array_filter(), and avoid the unset() call.

$list = "item to BE filtered<br>test<br>test<br>text another item to BE filtered";

$array = explode("<br>", $list);
$other = array_filter($array, function($value) {
    return stripos($value,'item to be filtered') === FALSE &&
        stripos($value,'another item to be filtered') === FALSE;
});

$newcontent = "<pre>".implode("\n", $other)."</pre>";

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top