It is necessary to clear the html code from the styles that the visual editor has written to it. I do this:
$handle = @fopen("new_item.htm", "r"); if ($handle) { while (!feof($handle)) { $buffer= fgetss($handle, 4096,'<img>,<title>,</title>,<table>,<tr>,</tr>,<td></td>,</table>'); $html_clean= trim(preg_replace('/<([az][a-z0-9]*)[^>]*?(\/?)>/i','<$1$2>',$buffer)); echo($html_clean); } fclose($handle); } As a result, I get the required type of code, but with the empty contents of the <img> .
How to add a regular season so that it also ignores the contents of the <img> ?
I want to get something like:
<table> <tr><td><img src="/path/img.jpg" width="100" height="400"></td></tr> </table>
preg_replace('/<img\b[^<]*>(*SKIP)(*F)|<([az][a-z0-9]*)[^>]*?(\/?)>/i','<$1$2>',$buffer)? - Wiktor Stribiżew