simply i have string like:
<h2 Article name</h2>This is an idea.<ul style="color:green;"><li>option 1</li><li>option 2</li><li>option 1<li></ul>
As you can see it is not valid, how can symfony or just PHP detect this and return where the error is?
I have found the following code:
private function validateHTML($string)
{
preg_match_all('#<(?!meta|img|br|hr|input\b)\b([a-z]+)(?: .*)?>#iU', $string, $result);
$openedTags = $result[1];
preg_match_all('#</([a-z]+)>#iU', $string, $result);
$closedTags = $result[1];
$len_opened = count($openedTags);
return (count($closedTags) == $len_opened) ? $string : false;
}
but it works sometimes good, but not for the example i had noticed at the top for example.
I am using symfony 4.2