Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

preg_match_all & regexp

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

preg_match_all & regexp

Postby ashok » Mon May 13, 2013 3:46 am

Hello,

I am not getting any output with this code. Is the regular expression correct?

url to match http://site.com/catalog/?car=532&city[0]=2&page=1&search=1

my code:
Code: Select all
public function get_vendors() {

      $url = $this->generate_url(intval($_REQUEST['id']));
        $a = $this->http->open($url,'http://site.com/catalog/');

        $vendros = array();

        if (preg_match_all("/href=\"\?car=([0-9]*)&[a-z0-9&=&%]*\">([a-z0-9\s\-а-яА-Я\/`\(\)'\"]*)<\/a>/Uims",$a,$m)) {
         foreach($m[1] as $k => $v) {
            $vendors[$v] = $m[2][$k];

         }

         return $vendors;

        }

   }
ashok
New php-forum User
New php-forum User
 
Posts: 1
Joined: Mon May 13, 2013 3:24 am

Re: preg_match_all & regexp

Postby johnj » Tue May 14, 2013 5:53 am

johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm


Return to PHP coding => General

Who is online

Users browsing this forum: Google Feedfetcher and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron