PHP中的数组过滤器

I am using a simple html dom to parsing html file.

I have a dynamic array called links2, it can be empty or maybe have 4 elements inside or more depending on the case

<?php
include('simple_html_dom.php');

$url = 'http://www.example.com/';

$html = file_get_html($url);
$doc = new DOMDocument();
@$doc->loadHTML($html);
//////////////////////////////////////////////////////////////////////////////
foreach ($doc->getElementsByTagName('p') as $link) 
{

    $intro2 = $link->nodeValue;

    $links2[] = array(
        'value' => $link->textContent, 

    );

    $su=count($links2);   
}

$word = 'document.write(';

Assuming that the two elements contain $word in "array links2", when I try to filter this "array links2" by removing elements contains matches

unset( $links2[array_search($word, $links2 )] );
print_r($links2);

the filter removes only one element and array_diff doesn't solve the problem. Any suggestion?

solved by adding an exception

foreach ($doc->getElementsByTagName('p') as $link) 
{
$dont = $link->textContent;
 if (strpos($dont, 'document') === false) {




   $links2[] = array(
        'value' => $link->textContent, 

                                        );
    } 
    $su=count($links2);
     echo $su;