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? Quote 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? Quote 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)); Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.