how can it be that strings containing æøå or other special chars is returned as null?? not only the special char is leaved but the whole string (value) is returned as null...
EDIT:
class JSON {
static function encode($arr, $utf8_encode=false){
$arr = self::parse_int($arr);
if($utf8_encode){
array_walk_recursive($arr, array(self => 'utf8_enc'));
}
return $arr ? json_encode($arr):'{}';
}
static function decode($str){
return json_decode($str, true);
}
function utf8_enc(&$value, $key){
$value = utf8_encode($value);
}
function parse_int($arr){
foreach($arr as $key => $value){
if(is_array($value)){
$arr[$key] = self::parse_int($value);
}
else{
if(is_numeric($value)){
settype($value, 'float');
}
$arr[$key] = $value;
}
}
return $arr;
}
}
but I get this error:
Warning: array_walk_recursive() expects parameter 2 to be a valid callback, array must have exactly two members
in this line:
array_walk_recursive($arr, array(self => 'utf8_enc'));
how do you define a function in the current object?