Re: String check

From: Date: Tue, 30 Apr 2002 12:20:17 +0000
Subject: Re: String check
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-95369@lists.php.net to get a copy of this message
I wouldn't recommend ereg() unless you have some complex pattern matching to do. If you're always looking for the same string, in the same spot,then just use substr(). Now...if you want to match _any_ 3 numbers, etc, then that's when ereg() comes into play. ---John Holmes... ----- Original Message ----- From: "Justin French" <justin@indent.com.au> To: <david@atom.is>; <php-general@lists.php.net> Sent: Tuesday, April 30, 2002 8:15 AM Subject: Re: [PHP] String check eregi() is the go... whilst the documentation is pretty thin on the actual expressions, '^' checks for the pattern at the begining of a string. <? if(eregi('^324', $string)) { // // it did begin with "324" // } else { // // it didn't // } ?> Justin French -------------------- Creative Director http://Indent.com.au -------------------- on 30/04/02 10:03 PM, David Orn Johannsson (david@atom.is) wrote: > Is ther any function that I could use to check if a string beguins wiht > a certin set of numbers, like > if string starts_w "324" { > do some stuff; > } > > Regards, David > > <http://www.atom.is/> ------------------------ > Davíð Örn Jóhannssson > Vefforritari > ------------------------ > Atómstöðin hf. > Garðastræti 37 > 101 Reykjavík > ------------------------ > sími: 595-3643 > fax: 595-3649 > <mailto:david@atom.is> david@atom.is > <http://www.atom.is/> > http://www.atom.is > ------------------------ > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#95369) next »