$response = curl_exec($ch);
preg_match_all('/^Location:(.*)$/mi', $response, $matches);
curl_close($ch);
使用此脚本,我得到输出: http://website.com/632383970568166e82391f.png
我需要提取ID,这是abcdef并在另一个调用中使用它。我怎样才能做到这一点?
答案 0 :(得分:0)
使用正则表达式或执行此操作:
$url = "http://subdomain.website.com/something/folder1/folder2/folder3/folder4/folder5/20385425_632383970568166e82391f.png";
$urlParts = explode('/', $url)
$imgFileParts = explode('_', $urlParts[(count($urlParts) - 1)]);
$imgId = $imgFileParts[0];
答案 1 :(得分:0)
$re = "/\\S+\\/([\\S]+)_/";
$str = "http://subdomain.website.com/something/folder1/folder2/folder3/folder4/folder5/20385425_632383970568166e82391f.png";
preg_match($re, $str, $matches);