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 custom_json_decode(&$contents=NULL, $normalize_contents=true, $force_array=true){ | |
//---------------decode contents--------------------- | |
$decoded_contents=NULL; | |
if(is_string($contents)){ | |
$decoded_contents=json_decode($contents,$force_array); | |
} | |
//---------------normalize contents--------------------- | |
if($normalize_contents===true){ | |
if(is_string($decoded_contents)){ | |
if($decoded_contents==='NULL'||$decoded_contents==='null'){ | |
$contents=NULL; | |
} | |
elseif($decoded_contents==='FALSE'||$decoded_contents==='false'){ | |
$contents=false; | |
} | |
} | |
elseif(!is_null($decoded_contents)){ | |
$contents=$decoded_contents; | |
} | |
} | |
else{ | |
//---------------validation contents--------------------- | |
$contents=$decoded_contents; | |
} | |
return $contents; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use