Danny620 Posted May 8, 2012 Share Posted May 8, 2012 If i run data that has HTML entities such as ( ) though json_encode($results) it seems to produce NULL any ideas? Link to comment https://forums.phpfreaks.com/topic/262254-problem-json_encoderesults-with-data-like-nbsp/ Share on other sites More sharing options...
trq Posted May 8, 2012 Share Posted May 8, 2012 Code? Link to comment https://forums.phpfreaks.com/topic/262254-problem-json_encoderesults-with-data-like-nbsp/#findComment-1343972 Share on other sites More sharing options...
Danny620 Posted May 8, 2012 Author Share Posted May 8, 2012 function Pretty_JSON($json){ $pattern = array(',"', '{', '}'); $replacement = array(",\n\t\"", "{\n\t", "\n}"); return str_replace($pattern, $replacement, $json); } $blogs[] = array( 'blog_id' => ($row['ID']), 'post_date' => ($row['pd']), 'post_title' => (html_entity_decode($row['post_title'], ENT_QUOTES)), 'blog_img' => ('http://www.socialnewsoffice.com/uploads/'.$row['article_img']), 'post_content' => (html_entity_decode($row['post_content'], ENT_QUOTES)), 'tags' => ($row['tags']), 'views' => ($row['views']), 'categorie_id' => ($row['categorie_id']), 'post_url' => ($row['post_url'])); } $results[] = array( 'data' => ($blogs), 'start' => ("$start"), 'pages' => ("$pages"), 'display' => ("$display")); echo $json = Pretty_JSON(json_encode($results)); Link to comment https://forums.phpfreaks.com/topic/262254-problem-json_encoderesults-with-data-like-nbsp/#findComment-1343975 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.