PHP Regular Expressions
This is a good little tutorial page I found on php regular expressions.
//checks to see if shutter speed is recorded as fraction or in full seconds
if (preg_match("%/%",$query['speed'])){$ss_terminology='th of a second';} else
{ $ss_terminology=' seconds';}
UPDATE 1/6/07!!
I needed to use preg_match on my search gallery page to add a wildcard asterick * to the end of a passed search term if someone might type "tn_filename" in the search field looking for an image they came across via the Google image search. I was running into some difficulty which prompted me to post in the PHP Freaks forum. It turns out I wasn't including delimiters!if (preg_match("^tn%",$myword)) { do something...
should be this:
if (preg_match("/^tn%/",$myword)) { do something...
or
if (strpos($myword,"tn")===0) { do something...
0 Comments:
Post a Comment
<< Home