首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用EXTJS发布JSON数据(带有重音的字符),用PHP保存

用EXTJS发布JSON数据(带有重音的字符),用PHP保存
EN

Stack Overflow用户
提问于 2017-12-06 13:12:39
回答 1查看 33关注 0票数 0

对不起,我的英语,我是巴西人。

在我的表单中,我将数组中的数据发送到php数据库中保存.我输入de word“8‘ANDAR”并将extjs发送到php "8\u00ba ANDAR“(在此之前没有问题),但是如何用php将"8\u00ba ANDAR”还原为“8’ANDAR”呢?

我试过,但没有成功..。这里是我用ExtJS发布的数据这里是我在php中的代码:

代码语言:javascript
复制
if(in_array($_POST['action'], array('INSERIR', 'EDITAR')) and isset($_POST['ambientes'])){
    $ambientes = json_decode(stripcslashes('['.$_POST['ambientes'].']'), true);
    foreach ($ambientes as $key => $item) {
        //need to revert the $nome_ambiente....
        $nome_ambiente = mb_strtoupper(trim($item['ambiente']));
        $nome_ambiente = ReformatString($nome_ambiente);
        $nome_ambiente = preg_replace('/\s(?=\s)/', '', $nome_ambiente);
        $nome_ambiente = preg_replace('/[\n\r\t]/', ' ', $nome_ambiente);

        $obs_ambiente = mb_strtoupper($item['observacoes'], 'UTF-8');
        $obs_ambiente = ReformatString($obs_ambiente);

        $sqlA = "SELECT count(*) FROM ambientes_nomes WHERE descricao='$nome_ambiente'";
        $pdoA = $connection->prepare($sqlA);
        $pdoA->execute();
        $num_rows = $pdoA->fetchColumn();

        if($num_rows < 1){
            $sqlB = "INSERT INTO ambientes_nomes (descricao, cadastrado_por, alterado_por, data_cadastro, data_alteracao) VALUES ('$nome_ambiente', $user_id, $user_id, '$data_atual', '$data_atual')";
            $pdoB = $connection->prepare($sqlB);
            $pdoB->execute();
        }
    }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-12-06 13:15:46

如何用php将"8\u00ba ANDAR“还原为”8‘ANDAR“?

json_decode('['.$_POST['ambientes'].']', true)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47675171

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档