I can not find a solution.
How to check string with the html code.
example
<p><o:p></o:p></p>
<p> <br /> </p>
<p><b style=\"font-weight: bold;\"><b>Desc: </b>AnyText.</p>
<br /> </p>
<p><b>Color:</b> green<
<p> <b>Param 2: AU55688</p>
<p><b>Param 3: </b>420 x 562</p>
<p><b>Height: </b>1425</p>
If there are unclosed tags or undiscovered, then return string if all is well, then skip.
I found and modified function. But it does not work properly
function closetag($html)
{
$ignore_tags = array('img', 'br', 'hr');
preg_match_all ( "#<([a-z]+)( .*)?(?!/)>#iU", mb_strtolower($html), $result1);
preg_match_all ( "#</([a-z]+)>#iU", mb_strtolower($html), $result2);
$results_start = $result1[1];
$results_end = $result2[1];
$result = array();
foreach($results_start AS $startag)
{
if (!in_array($startag, $results_end) && !in_array($startag, $ignore_tags))
{
$result['start_tags'][] = $startag;
}
}
foreach($results_end AS $endtag)
{
if (!in_array($endtag, $results_start) && !in_array($endtag, $ignore_tags))
{
$result['end_tags'][] = $endtag;
}
}
return ($result) ? $result : false;
}
I do not need to correct the code, I need only determine that the syntax is not correct.
An example of what I want to get a result
$getTexts = $this->getTexts();
$no_valid = array();
foreach($getTexts AS $text)
{
$_valid = check_html_systax_function($text);
if (!$_valid)
{
$no_valid[] = $text;
}
}
check_html_systax_function checks texts for correct html syntax
$no_valid array of texts in which errors in html syntax
P.S. Sorry for my English!