Link to home
Start Free TrialLog in
Avatar of dschrishuhn
dschrishuhn

asked on

php preg_match no ending delimiter

Hi Everyone,

I'm getting:

Warning: preg_match() [function.preg-match]: No ending delimiter '^' found in C:\XAMPP\xampp\htdocs\shop\includes\classes\language.php on line 87


Thanks for your help, I'm new to php.

-Omar
Avatar of dschrishuhn
dschrishuhn

ASKER


function get_browser_language() {
      $this->browser_languages = explode(',', getenv('HTTP_ACCEPT_LANGUAGE'));

      for ($i=0, $n=sizeof($this->browser_languages); $i<$n; $i++) {
        reset($this->languages);
        while (list($key, $value) = each($this->languages)) {
          if (preg_match('^(' . $value . ')(;q=[0-9]\\.[0-9])?$', $this->browser_languages[$i]) && isset($this->catalog_languages[$key])) {
            $this->language = $this->catalog_languages[$key];
            break 2;
          }
        }
      }
    }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sorry for not being clear.  The /'s worked like a charm.

Thank you very much! I knew it had to be a simple syntax error.

-Omar
There may be a simpler solution - can you tell us what the desired output is?  Thanks, ~Ray
Thanks - you guys are awesome!
@dschrishuhn: You accepted the second solution - exactly the same code snippet as what I had posted earlier.  I will ask a moderator to reopen the question so you can award the points appropriately.  But if you would just take a moment to tell us what you want out of this code snippet maybe we can help you get a clearer and more dependable solution than REGEX.  Thanks, ~Ray
Sorry Ray, I agree.  I didn't realize I had refreshed the page.  And both comments were so close together that I accidentally accepted the second. I thought it was yours, hence the comment. (j/k, btw)

I upgraded apache servers and was converting the deprecated ereg() functions to preg_match.

Yeah, I have been replacing EREG with PREG, too.  A lot of it is just adding the delimiters, a little is adding the "i" where I used EREGI before.
Thanks for the points - I still think that a REGEX may not be the best design pattern here, but that is just a guess - not completely sure what your needed output would be, but if you want to describe it, there may be another way to skin this cat.

best regards, ~Ray
Please don't yell :-P
Merry Christmas to all... ~Ray