How to make a JPG image at the beginning of HTTP

Source: Internet
Author: User
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
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.