> -----Original Message----- > From: parasane@xxxxxxxxx [mailto:parasane@xxxxxxxxx] On > Behalf Of Daniel Brown > Sent: Monday, January 25, 2010 6:43 PM > To: John Taylor-Johnston > Cc: PHP-General > Subject: Re: If the first four characters are "0000", then do {} > > On Mon, Jan 25, 2010 at 21:36, John Taylor-Johnston > <John.Taylor-Johnston@xxxxxxxxxxxxxxxxxxxxx> wrote: > > I am reading the manual: http://ca.php.net/manual/en/ref.strings.php > > > > $mydata->restored = "0000-00-00"; > > <?php > > $o[] = '0942-23-23'; > $o[] = '0000-00-00'; > $o[] = '1238-00-00'; > $o[] = '0001-23-45'; > $o[] = '0000-11-22'; > > for($i=0;$i<count($o);$i++) { > if(preg_match('/^[0]{4,}\-/U',$o[$i])) { > echo "Offset #".$i." matches: ".$o[$i].PHP_EOL; > } > } > ?> Holy macaroni. Talk about overkill! if (substr($mydata->restored,0,4) == "0000") { } Or in your very specific case you could do the harder way and note that strings work like simple arrays too in a way, so $mydata->restored{0} through $mydata->restored{3} should all be '0' ( note the {} and not [] ). You can use a forloop or just manually check them all with && or || or whatever logic you feel comfortable with. But the substr is by far the simplest. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php