I want to extract only text from a php string.
This php string contains html code like tags or etc.
So I only need a simple text from this string.
<Another option is to use Html2Text. It will do a much better job than strip_tags, especially if you want to parse complicated HTML code.
Extracting text from HTML is tricky, so your best bet is to use a library built for this purpose.
https://github.com/mtibben/html2text
Install using composer:
composer require html2text/html2text
Basic usage:
$html = new \Html2Text\Html2Text('Hello, "<b>world</b>"');
echo $html->getText(); // Hello, "WORLD"
You may try:
echo(strip_tags($your_string));
More info here: http://php.net/manual/en/function.strip-tags.php
Adding another option for someone else who may need this, the Stringizer library might be an option, see Strip Tags.
Full disclosure I'm the owner of the project.