如何通过PHP

问题描述:

我使用Facebook的API解码 '\ u0040' 到 '@',但Json的返回:如何通过PHP

{ 
    "id": "674271626114503", 
    "email": "duc2521997\u0040gmail.com" 
} 

如何通过PHP解码 '\ u0040' 到 '@'? 谢谢。

+0

只有采取简单的选项是不被接受的回答并使用'json_decode()' – RiggsFolly

试试这个,在这里我们使用json_decode将自己照顾\u0040@

Try this code snippet here

<?php 
ini_set('display_errors', 1); 
$string='{ 
    "id": "674271626114503", 
    "email": "duc2521997\u0040gmail.com" 
}'; 
$array= json_decode($string,true); //this itself will take care of `\u0040` 
echo $array["email"]; 

输出:[email protected]

+0

它工作!谢谢 –

+0

@ĐứcNguyễn欢迎朋友.... :) –

+0

'utf8_decode()'是不必要的。它没有工作很愉快。见https://eval.in/794819 – RiggsFolly