note 99987 added to function.json-encode
| From: | robbiz233 at hotmail dot com | Date: | Sat, 18 Sep 2010 07:24:31 +0000 |
| Subject: | note 99987 added to function.json-encode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-172707@lists.php.net to get a copy of this message | ||
The comment below for utf8 safe encoding has a slight bug in it.
$newArray[$key] = utf8json($inArray); should be $newArray[$key] = utf8json($val);
Included the whole piece of code below.
<?php
json_encode(utf8json($dataArray));
function utf8json($inArray) {
static $depth = 0;
/* our return object */
$newArray = array();
/* safety recursion limit */
$depth ++;
if($depth >= '30') {
return false;
}
/* step through inArray */
foreach($inArray as $key=>$val) {
if(is_array($val)) {
/* recurse on array elements */
$newArray[$key] = utf8json($val);
} else {
/* encode string values */
$newArray[$key] = utf8_encode($val);
}
}
/* return utf8 encoded array */
return $newArray;
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 114.76.98.250
----
Manual Page -- http://www.php.net/manual/en/function.json-encode.php
Edit -- https://master.php.net/note/edit/99987
Del: integrated -- https://master.php.net/note/delete/99987/integrated
Del: useless -- https://master.php.net/note/delete/99987/useless
Del: bad code -- https://master.php.net/note/delete/99987/bad+code
Del: spam -- https://master.php.net/note/delete/99987/spam
Del: non-english -- https://master.php.net/note/delete/99987/non-english
Del: in docs -- https://master.php.net/note/delete/99987/in+docs
Del: other reasons-- https://master.php.net/note/delete/99987
Reject -- https://master.php.net/note/reject/99987
Search -- https://master.php.net/manage/user-notes.php