preg_match_all clearing different tags

There is a lot of html garbage in the description of the store’s products.
There are descriptions of this kind

<ul>
   <li><span class="Apple-style-span" style="font-family: Arial, serif; font-size: 12px; "> </span></li>
   <li><span class="Apple-style-span" style="font-family: Arial, serif; font-size: 12px; "> <span class="Apple-tab-span" style="white-space: pre; ">    </span>5 </span></li>
   <li><span class="Apple-style-span" style="font-family: Arial, serif; font-size: 12px; "> <span class="Apple-tab-span" style="white-space: pre; ">    </span>50 </span></li>
   <li><span class="Apple-style-span" style="font-family: Arial, serif; font-size: 12px; "> <span class="Apple-tab-span" style="white-space: pre; ">    </span>0,6 </span></li>
   <li><span class="Apple-style-span" style="font-family: Arial, serif; font-size: 12px; "> <span class="Apple-tab-span" style="white-space: pre; ">    </span>0,34 </span></li>
   <li><span class="Apple-style-span" style="font-family: Arial, serif; font-size: 12px; ">  (//) 7418,818,8 </span></li>
   <li><span class="Apple-style-span" style="font-family: Arial, serif; font-size: 12px; ">  </span></li>
   <li><span class="Apple-style-span" style="font-family: Arial, serif; font-size: 12px; ">   </span></li>
   <li><span class="Apple-style-span" style="font-family: Arial, serif; font-size: 12px; ">    </span></li>
   </ul>

and this kind

<div> 
<ul>
   <li>3  1: , , </li>
   <li>    </li>
   <li>     </li>
   <li> </li>
   <li>2  </li>
   <li> </li>
   <li> </li>
   <li>: 700 </li>
  </ul>
</div>

And that’s not all the happiness I get.

I need to clear this description from html, keeping the lines, that is, to show the user like this:

  • Kitchen scale Max weight 5
  • Graduation 50 g
  • List item
  • Gross weight 0.6 kg
  • List item
  • List item

I do this: preg_match_all("|<[^>]+>(.*)</[^>]+>|U",$mytext,$out, PREG_PATTERN_ORDER);

But spans etc are not cleared. Please help me write the correct regular expression.


Answer 1, authority 100%

<?
$content = $arResult['DETAIL_TEXT'];
$content = explode('###', strip_tags(str_replace('<li>', '###', $content)));
// 1)   <li>(   100%  )
//  ###(    );
// 2)  strip_tags ( "test1###test2###test3");
// 3)     ###
// ,    =)
foreach ($content as $n => $str)
  if (!trim($str))
    unset($content[$n]);
$out = array(array(), array());
$count2 = floor(count($content)/2);
$n = 0;
foreach ($content as $str) {
  $out[intval($n>$count2)][] = trim($str);
  $n++;
  }
// var_dump($out); // 0 -  , 1 - .
echo '<ul>';
echo '<li><h4> </h4></li>';
foreach($out[0] as $str)
  echo '<li>'.$str.'</li>';
echo '</ul>';
echo '<ul>';
echo '<li><h4> </h4></li>';
foreach($out[1] as $str)
  echo '<li>'.$str.'</li>';
echo '</ul>';
?>

Answer 2

If you need to strip a string of tags, use strip_tags. You can “kill” everything except ul and li and show.