On 25 August 2008 00:54, Govinda advised: >> >> >> if (stripos(strrev($file), "gpj.") === 0) { >> echo $file; >> } >> >> note the ===, 3 equals signs here is very important! check the docs >> for why. > > == means 'equals', and === means 'is identical to'. > Seems like they would do the same thing when comparing '0' to 'the > position in the string where that substr is found'. Why not? They would -- but stripos will also return FALSE if there is no match, and FALSE==0 too! >> or you could go a little more robust with regular expressions >> >> if (preg_match("#^.*\.(jpe?g|gif|png)$#i", $file) { >> echo $file; // any image file is echo'ed >> } > ahhh reg expressions. So looking forward to when I can see PHP > properly/clearly enough to throw them in too! (meanwhile I better get > the basics first ;-) Personally, I might be tempted to do something like this: if (($pos = strrchr($file, '.'))!==FALSE): switch (strtolower(substr($file, $pos))): case '.gif': case '.png': case '.jpg': case '.jpeg': echo $file; endswitch; endif; But then, I might go with the pattern match or the glob() solution, too! ;) Cheers! Mike -- Mike Ford, Electronic Information Developer, C507, Leeds Metropolitan University, Civic Quarter Campus, Woodhouse Lane, LEEDS, LS1 3HE, United Kingdom Email: m.ford@xxxxxxxxxxxxxx Tel: +44 113 812 4730 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php