How to extract a relative address from a remote picture URL address and create a folder
$imgurl = "Http://www.111cn.net/images/l/201011/sjfzgm1289209745159.jpg";
Remove "http:/"
$imgurl 2 = substr ($imgurl, 6);
$imgurl 3 = strstr ($imgurl 2, '/'); This becomes: $imgurl 3 = = "/images/l/201011/sjfzgm1289209745159.jpg";
Next Flip the string
$imgurl 4 = Strrev ($imgurl 3); This becomes: $imgurl 4 = = "/gpj.9515479029821mgzfjs/110102/l/segami/";
Remove the "/"
$imgurl 4 = substr ($imgurl 3,1); This becomes: $imgurl 4 = = "gpj.9515479029821mgzfjs/110102/l/segami/";
Remove file name
$imgurl 5 = strstr ($imgurl 4, '/'); This becomes: $imgurl 4 = = "/110102/l/segami/";
Flip again, restore
$imgurl 6 = Strrev ($imgurl 5); This becomes: $imgurl 6 = = "/images/l/201011/";
/*
Usually the Match.
There are also URLs ("")
Then get the relative address, first judge the domain name this to find
.. /
./
/
So three kinds are the performance of the catalogue
The picture has an extension of just a few
It's supposed to be written.
*/
Use regular to extract the contents of the label
$str = ' <p> text </p>
<span> Text 2
</span> ';
$preg = '/<.+?> (. +?) </.+?>/is ';
Preg_match_all ($preg, $str, $result);
Print_r ($result [1]);