如何忽略span标签dom html

Hi i am trying to scrape Brand New Apple iPhone 8 64GB or 256GB - Sealed - GSM Unlocked in this code but it also scrape span with it, how do i ignore span text.

<h1 class="it-ttl" itemprop="name" id="itemTitle"><span class="g-hdn">Details about  &nbsp;</span>Brand New Apple iPhone 8 64GB or 256GB - Sealed - GSM Unlocked</h1>

This is the code :

$productname = $html->find("h1[class='it-ttl']",0)->plaintext;

echo $productname;

strip_tags_content is a function which is written in PHP Strip Tags and owner of the function is explains with these words. You can find more examples inside the link.

Output is: Brand New Apple iPhone 8 64GB or 256GB - Sealed - GSM Unlocked

"Hi. I made a function that removes the HTML tags along with their contents "

 function strip_tags_content($text, $tags = '', $invert = FALSE) {

        preg_match_all('/<(.+?)[\s]*\/?[\s]*>/si', trim($tags), $tags);
        $tags = array_unique($tags[1]);

        if(is_array($tags) AND count($tags) > 0) {
            if($invert == FALSE) {
                return preg_replace('@<(?!(?:'. implode('|', $tags) .')\b)(\w+)\b.*?>.*?</\1>@si', '', $text);
            }
            else {
                return preg_replace('@<('. implode('|', $tags) .')\b.*?>.*?</\1>@si', '', $text);
            }
        }
        elseif($invert == FALSE) {
            return preg_replace('@<(\w+)\b.*?>.*?</\1>@si', '', $text);
        }
        return $text;
    }


    $string = '<h1 class="it-ttl" itemprop="name" id="itemTitle"><span class="g-hdn">Details about  &nbsp;</span>Brand New Apple iPhone 8 64GB or 256GB - Sealed - GSM Unlocked</h1>';
    $string = strip_tags_content($string,'<span>',true);
    $string = strip_tags($string);

    echo $string;

For your problem after defining this function just call

$productname = $html->find("h1[class='it-ttl']",0)->plaintext; 
$productname = strip_tags_content($productname ,'<span>',true); 
$productname = strip_tags($string);