How do I make a JPG image at the beginning of http?
I use simple_html_dom.php, will only find the HTTP beginning of the picture, how to add a jpg end of the judgment?
Or
Who writes a JPG image that preg_match_all all HTTP starts? Thank you.
Share to:
------Solution--------------------
Not too understand what you want to say, this is what I wrote when I learned the regular, get a picture of the web,
/*
* @param string $url capture URL
* @param int $isinsite is the station within the default 1 is the station within 0 stations outside the station
* @return String
*/
function getallimg ($url, $isinsite =1)
{
$urlstr =parse_url ($url);
$url = $urlstr [scheme]? $url: "/http". $urlstr [path];//Determines if the user input URL contains http://And then complements it.
$urlstr =parse_url ($url);
$site = "http://". $urlstr [host];//take the address of the site
$subject =file_get_contents ($url);
$pattern = '/.*------solution--------------------
\ "] (. *[.jpg
------Solution--------------------
. gif
------Solution--------------------
. png]) [\ '
------Solution--------------------
\"].*\/?? >.*/u ';//The Delimiter
Preg_match_all ($pattern, $subject, $result);//Find All matches
if ($isinsite ==0)
{
foreach ($result as $key + $value)//two-D array $result[n][m];
{
if ($key ==1)
{
foreach ($value as $key = + $value)//Fetch $RESULT[M]
{
$isownsite =parse_url ($value);
$url = $isownsite [host]? $value: $site. $isownsite [path];//get all pictures of the page also other URLs
$imgcontent. = "
------Solution--------------------
";
}
}
}
}
if ($isinsite ==1)
{
foreach ($result as $key + $value)//two-D array $result[n][m];
{
if ($key ==1)
{
foreach ($value as $key = + $value)//Fetch $RESULT[M]
{
$isownsite =parse_url ($value);
$url = $isownsite [host]? NULL: $site. $isownsite [path];//only gets the site without external URLs
if ($url!=null)
$imgcontent. = "
------Solution--------------------
";
}
}
}
}
return $imgcontent;
}
?>
Look for pictures in the whole station
Look for the whole station outside the station picture