naeemqaswar
8/25/2019 - 11:34 AM

JSON Encode results blank (JSON_ERROR_UTF8 )

<?php

// Before encoding array, pass array to function "utf8ize" to prevent blank result
echo json_encode(utf8ize($location_data));

function utf8ize($mixed) {
    if (is_array($mixed)) {
        foreach ($mixed as $key => $value) {
            $mixed[$key] = utf8ize($value);
        }
    } else if (is_string ($mixed)) {
        return utf8_encode($mixed);
    }
    return $mixed;
}