View Single Post
  #13 (permalink)  
Old 12-18-2007, 06:19 AM
Sabari Sabari is offline
D-Web Genius
 
Join Date: Jul 2007
Posts: 1,008
Sabari is on a distinguished road
Default Re: PHP Tips and Tricks

Don't use a regex if you don't have to

PHP has a rich set of string manipulation functions - use them!

BAD: <? $new = ereg_replace("-","_",$str); ?>
GOOD:<? $new = str_replace("-","_",$str); ?>
BAD: <? preg_match('/(\..*?)$/',$str,$reg);?>
GOOD:<? substr($str,strrpos($str,'.')); ?>
__________________
Thanks & Regards
Sabari...
Reply With Quote