Created
August 1, 2012 21:40
-
-
Save davidrenne/3230999 to your computer and use it in GitHub Desktop.
json_encode_non_buggy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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