对不起,我的英语,我是巴西人。
在我的表单中,我将数组中的数据发送到php数据库中保存.我输入de word“8‘ANDAR”并将extjs发送到php "8\u00ba ANDAR“(在此之前没有问题),但是如何用php将"8\u00ba ANDAR”还原为“8’ANDAR”呢?
我试过,但没有成功..。这里是我用ExtJS发布的数据这里是我在php中的代码:
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();
}
}
}发布于 2017-12-06 13:15:46
如何用php将"8\u00ba ANDAR“还原为”8‘ANDAR“?
json_decode('['.$_POST['ambientes'].']', true)
https://stackoverflow.com/questions/47675171
复制相似问题