我有一个变量美元uuid = {" uuid":" 28 fb72ed 4 - 0 - e97 e78 - 9404 b676289b33ee "};
执行后得到的
我需要提取28fb72ed-0e97-4e78-9404-b676289b33ee只是数字
如何在PHP中实现
我在这里包含了一些代码我正在使用crocodoc查看器,我已经使用鳄鱼API生成了流体现在检查状态,我需要液体单独…它传递的是整个变量我必须分开并单独获得uid
$ch = curl_init();
@curl_setopt($ch, CURLOPT_HEADER, 0);
@curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json', 'X-HTTP-Method-Override: POST'));
@curl_setopt($ch, CURLOPT_POST, 1);
@curl_setopt($ch, CURLOPT_POSTFIELDS,$param);
@curl_setopt($ch, CURLOPT_URL, $frameUrl);
@curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
@curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
$uuids = curl_exec($ch);
echo $uuids;
echo "nnchecking status of : ", $uuids;
$status =getStatus($uuids,$api_url,$myToken);
可能此处应该使用regex或explosion()或implode()函数
有人能帮帮我吗?
谢谢
2个解
使用JSON更容易:
$str = '{"uuid": "28fb72ed-0e97-4e78-9404-b676289b33ee"}';
$obj = json_decode($str);
echo $obj->uuid;
输出:28fb72ed-0e97-4e78-9404-b676289b33ee
Second with Regex
$str = '{"uuid": "28fb72ed-0e97-4e78-9404-b676289b33ee"}';
preg_match('/"uuid": "([^"]+?)"/', $str, $matches);
print_r($matches);
输出:Array ( [0] => "uuid": "28fb72ed-0e97-4e78-9404-b676289b33ee" [1] => 28fb72ed-0e97-4e78-9404-b676289b33ee )
$matches[1]
有你需要的价值
Try with
echo $uuid->uuid;
下面的代码将解决您的错误:
preg_replace('/{}/', '', $uuids);