[英]Find a string between 2 strings with a match
我的字符串是这样的
file: "http://website.com/640/image.jpg", type: 'jpg', quality: "640"
如果可能的话,我想以这2种不同的方式获取链接
如果它在“和”之间,并且与链接内的640相匹配
或者如果它在文件之间:“和”,则输入:'jpg',质量:“640
如何使用preg_match()或其他函数执行此操作?
似乎没有{和}的JSON格式。
尝试:
$str = '{' . $str . '}';
json_decode($str);
http://php.net/manual/en/function.json-decode.php
编辑:
要提取URL:
$pos = strpos($str, '"', 0);
$start = $pos + 1;
$pos = strpos($str, '"', $start);
$end = $pos - 1;
$url = substr($pos, $start, ($end - $start) - 1);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.