-1

Possible Duplicate:
How can I convert ereg expressions to preg in PHP?

I am getting the above (subject) error from:

if (ereg('<coordinates>([0-9.-]{1,}),([0-9.-]{1,}).*</coordinates>', $result, $regs))

So I did this:

if (preg_match('<coordinates>/[0-9.-]{1,}\/,\/[0-9.-]{1,}/.*</coordinates>/', $result, $regs))

Now the Google map doesn't show up at all and it also warns "..cannot find coordinates..."

Where did I go wrong?

Thanks!

Community
  • 1
  • 1
Jim
  • 1
  • 3

1 Answers1

0

You need delimiters around your pattern when using PCRE functions:

if (preg_match('~<coordinates>/[0-9.-]{1,}\/,\/[0-9.-]{1,}/.*</coordinates>/~', $result, $regs))

Notice the ~ at the beginning and end.
Normally, people use / as a delimiter, but because it shows up so frequently in your pattern, an alternate delimiter has been selected.

As @nickb mentioned, have a look at this discussion:
How can I convert ereg expressions to preg in PHP?

Community
  • 1
  • 1
Mr. Llama
  • 20,202
  • 2
  • 62
  • 115
  • Tried it. Now I am getting error: Unable to get map center coordinates, please verify your location! (249 Maitland...) – Jim Jan 21 '13 at 22:23