解析我无法识别为对象或数组或 JSON 的字符串


Parsing a string which I am not able to identify as Object or Array or Json

我正在接收一个数组以响应请求。当我print_r它时,这就是我得到Array( [receiver] => {:email=>"email@domain.com"}).

我无法理解如何访问":电子邮件"的值。

请帮忙。

编辑:

这是回应的var_dump。

array ( 'receiver' => '{:email=>"email@domain.com"}' )

谢谢。

使用正则表达式获取电子邮件。

$arr = array('recebodor' => '{:email=>"someone@example.com"}');
$email = preg_replace('/{:email=>"([^"]+)"}/', '$1', $arr['recebodor']);
echo $email; // someone@example.com

解释:

{:email=>    Match with the "{:email=>" in the string
"([^"]+)"    Get any character within double quotes
}            Match with the last "}"
$1           Replace all text with the text found inside parentheses