I have to json_encode a PHP array to a JavaScript array. Unfortunately the jQuery library I am using will not properly process that array if it contains ints instead of stri
Because there isn't an opposite flag for JSON_NUMERIC_CHECK, I've created a function for that purpose.
It accepts one and multi dimensional arrays and there can be added for conditions to validate each element of te array.
function JSON_NUMERIC_STRING($array){
foreach($array as $key => &$value){
if(is_array($value)){
$value = iterateMA($value);
}elseif(is_numeric($value)){
$value = strval($value);
}
// add more conditions if needed...
}
return $array;
}
$array = JSON_NUMERIC_STRING($array);