note 103701 rejected from function.json-decode by danbrown
| From: | danbrown@php.net | Date: | Thu, 28 Apr 2011 19:57:40 +0000 |
| Subject: | note 103701 rejected from function.json-decode by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-179250@lists.php.net to get a copy of this message | ||
Note Submitter: mquirozm1984 at hotmail dot com
----
Pongo a la comunidad una función para transformar un JSON de ISO a UTF8
function iso_to_utf8_json($inArray)
{
static $profundidad = 0;
/* our return object */
$newArray = array();
//aqui valido que no se puede ingresar mas en profundidad
/* safety recursion limit */
if ($profundidad > '5') {
return false;
}
/* step through inArray */
foreach ($inArray as $key => $val) {
if (is_array($val)) {
/* recurse on array elements */
$profundidad++;
$newArray[$key] = iso_to_utf8_json($val);
} else {
/* encode string values */
$newArray[$key] = utf8_encode($val);
}
}
$profundidad--;
/* return utf8 encoded array */
return $newArray;
}
by Miguel Quiroz