Reply to Re: problem with if (ereg)

Your name:

Reply:


Posted by Janwillem Borleffs on 10/07/05 16:05

fender_gr wrote:
> I have tried the following but always matches the numbers accodring to
> the first if case :
>
> if (ereg("0030697", $myquery_called_number)) {
> $myquery_called_number='GENERAL'; } else { $myquery_called_number =
> "$myquery_called_
> number";}
>

For basic string matching, you should not use regexp, but simply:

if ($myquery_called_number == '0030697') {
...
}

If you still want you use regexp, you should indicate start and end
match of the pattern with '^' and '$':

if (ereg('^003069$', $myquery_called_number)) {
...
}

Or use preg_match, which generates less overhead then the ereg() function:

if (preg_match('/^003069$/', $myquery_called_number)) {
...
}


JW

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация