I have posts that save with html tags from a wysiwyg editor.
I want the json output to be stripped of all html tags.
Because strip_tags can sometimes remove the text, I'm using preg_replace like so:
$body = $row['content'];
//$body = strip_tags($body);
$body = preg_replace("/<img[^>]+\>/i", "", $body);
$regex_strip_tags = "/<[\/\!]*?[^<>]*?>/";
$body = preg_replace($regex_strip_tags, '' , $body);
stash it in an array:
$arr[] = array('body' => $body);
The problem is that when I echo json_encode($arr)
some entries appear null
but if I use print_r($arr)
I see everything as intended.
Not sure what's going on here.