数组,其中包含要在php中转换为json的印地语字体数据


Array with hindi font data to be converted to json in php

我在数据库中使用utf8_bin存储了印地语字体数据。我可以从数据库中获取它,并使用以下内容显示它:

但是,我希望输出是json格式,清楚地显示印地语字体数据。我尝试使用json_encode,但它返回的数据类似于:

{"title":"''u0938''u0942''u0930''u094d''u092f''u094b''u0926''u092f","details":{"title":"''u0905''u0928''u094d''u0917''u094d''u0930''u0947''u095b''u0940''u0938''u0947''u0939''u093f''u0928''u094d''u0926''u0940","details":"''u092a''u0930''u093f''u0935''u0930_094d''u0924''u0928'' u094d"}2{"title":"''u0932''u094b''u0915''u094d''u0938''u092d''u093e","details":

相反,我希望它像

{"title":सूर्योदय,"详细信息":सुबह् का समय्}

请建议

我认为这是默认行为。但是有两件事你可以试试

  1. 如果您使用的是PHP 5.4,则可以设置JSON_UNESCAPED_UNCODE选项标志
  2. 如果您使用的是另一个版本,请尝试以下解决方法:

    array_walk_recursive($array, function(&$item, $key) {
        if(is_string($item)) {
            $item = htmlentities($item);
        }
    });
    $json = json_encode($array);
    $rson = html_entity_decode($rson);