从给定的HTML代码中使用php获取内部html

This is a very basic question but could not found answer

I want to get the inner html using php from the following html code

<strong class="large t55">text only</strong>

I want to echo "text only" in simple text not in bold.

http://php.net/manual/en/function.strip-tags.php

echo strip_tags('<strong class="large t55">text only</strong>');

If you want to get just inner text, strip_tags fastest and easiest solution.

But for parsing HTML in general (f.e. to get attributes: name, class, ...) best solution is DOMDocument.

Try HTML DOM

<?php 
  $html= "<strong class='large t55'>text only</strong>";

  $dom = new domDocument('1.0', 'utf-8'); 
  $dom->loadHTML($html); 

  $dom->preserveWhiteSpace = false; 
  $hTwo= $dom->getElementsByTagName('strong'); 
  echo $hTwo->item(0)->nodeValue; 
 ?>