Skip to content

Instantly share code, notes, and snippets.

@davidrenne
Created August 1, 2012 21:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidrenne/3230999 to your computer and use it in GitHub Desktop.
Save davidrenne/3230999 to your computer and use it in GitHub Desktop.
json_encode_non_buggy
function json_encode_non_buggy($array, $return=false)
{
//fixes cases where json_decode will crap out.
foreach ($array as $k=>$v)
{
$array[$k] = str_replace(array("\t",'"'),array(" ","""), utf8_encode($v));
}
if($return)
{
return json_encode($array);
}
else
{
echo json_encode($array);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment