1

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.

1
  • the strong tag will make it Bold! Commented Oct 5, 2016 at 6:31

3 Answers 3

3

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

echo strip_tags('<strong class="large t55">text only</strong>');
Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

0

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; 
 ?>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.