Questions about getting information about PHP

Source: Internet
Author: User
Questions about getting information about PHP
 
    $baidu = "http://www.baidu.com/s?wd=site%3Ahao123.com";
$site =file_get_contents ($baidu);
$site = Iconv ("UTF-8", "GB2312", $site);
Ereg ("(.*)", $site, $count);
Print_r ($count); Get the number of good topics included in Baidu

?>

This will get the result: Array ([0] = [1] = Baidu search _site:hao123.com)
But:
 
    $baidu = "http://www.baidu.com/s?wd=site%3Ahao123.com";
$site =file_get_contents ($baidu);
$site = Iconv ("UTF-8", "GB2312", $site);
Ereg ("(. *)", $site, $count);
Print_r ($count); Get the number of good topics included in Baidu

?>

This is not going to be ...
To explain, and how to get Baidu included amount ....
------Optimal Solution--------------------

Preg_match ('% found related results (. *?) A. %i ', $site, $count);

------Other Solutions--------------------

The "." Inside the regular Matches any character except "\ n" and does not match Chinese.
Preg_match ('% found related results (. *?) A. %i ', $site, $count);
As in the following:
Preg_match ('/ found the relevant result number (. *?) A. /I ', $site, $count);

------Other Solutions--------------------
Reference:
PHP code?12preg_match ('% found related results (. *?) A. %i ', $site, $count);

In fact, this
Preg_match ('/ find the relevant number of results (. *). <\/strong>/i ', $site, $count);

is available.
------Other Solutions--------------------
% Find related results (. *?) A. % i key is the last "I" means ignoring case, if not add "I" also do not need "%"
------Other solutions--------------------
reference:
Reference:% just the start and end of the regular, you use/, #都可以的正则的开始和结束不是 ^$ first heard, teachable ...

You're talking about location matching.
------Other Solutions--------------------
% is just the start and end of the regular, you use/, #都可以的
------ Other Solutions--------------------
% is just the start and end of the regular, you use/, #都可 The start and end of the
regular is not the first time ^$ heard, educated ...
------Other Solutions--------------------
Learning, not very clear.
------Other Solution--------------------
is incorrectly written, "." You can match the Chinese
------Other Solutions--------------------
The problem is that it can be used to make good use of the regular.
------Other Solutions--------------------
Can you tell me why I want to add%?
------Other Solutions--------------------
This reply was deleted by the administrator in 2012-11-19 17:27:11
  • 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.