Regular Expressions-PHP extracts the text and href issues of a tag under a specified div in HTML

Source: Internet
Author: User

has been resolved, a bit messy, the speed is OK.


  (' Possible deep recursion attack '); } foreach ($array as $key = + $value) {if (Is_array ($value)) {arrayrecursive ($array [$key], $funct        Ion, $apply _to_keys_also);        } else {$array [$key] = $function ($value);            } if ($apply _to_keys_also && is_string ($key)) {$new _key = $function ($key);                if ($new _key! = $key) {$array [$new _key] = $array [$key];            Unset ($array [$key]); }}} $recursive _counter--;} /************************************************************** * * Convert an array to a JSON string (Chinese language compatible) * @param array $array the arrays to be converted * @ The JSON string converted by the return string * @access public * *************************************************************/function    JSON ($array) {arrayrecursive ($array, ' UrlEncode ', true);    $json = Json_encode ($array); Return UrlDecode ($json);}

url:http://www.hkxy.edu.cn/

:
I want to extract. Offer_box_wide1 the text and href of the A element how to break?

Reply content:

has been resolved, a bit messy, speed on the line.


  (' Possible deep recursion attack '); } foreach ($array as $key = + $value) {if (Is_array ($value)) {arrayrecursive ($array [$key], $funct        Ion, $apply _to_keys_also);        } else {$array [$key] = $function ($value);            } if ($apply _to_keys_also && is_string ($key)) {$new _key = $function ($key);                if ($new _key! = $key) {$array [$new _key] = $array [$key];            Unset ($array [$key]); }}} $recursive _counter--;} /************************************************************** * * Convert an array to a JSON string (Chinese language compatible) * @param array $array the arrays to be converted * @ The JSON string converted by the return string * @access public * *************************************************************/function    JSON ($array) {arrayrecursive ($array, ' UrlEncode ', true);    $json = Json_encode ($array); Return UrlDecode ($json);}

url:http://www.hkxy.edu.cn/

:
I want to extract. Offer_box_wide1 the text and href of the A element how to break?

The simplest way is to phpquery.

Refer to php simple HTML DOM Parser
http://simplehtmldom.sourceforge.net/
You can manipulate HTML as flexibly as the jquery selector.

  • 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.