我正在接收一个数组以响应请求。当我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