Re: Regular Expressions
| From: | Jim Lucas | Date: | Wed, 07 Nov 2007 04:15:31 +0000 |
| Subject: | Re: Regular Expressions | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-264159@lists.php.net to get a copy of this message | ||
Robert Cummings wrote:
On Tue, 2007-11-06 at 23:24 -0300, Martin Alterisio wrote:one mistake, your commas above, between the index and value, should be a "=>" instead2007/11/6, Alberto García Gómez <alberto@ipimtzcm.rimed.cu>:<?phpI'm a mess in regular expressions and I make this code: $link = ereg_replace('ñ','n',$link); $link = ereg_replace('á','a',$link); $link = ereg_replace('é','e',$link); $link = ereg_replace('í','i',$link); $link = ereg_replace('ó','o',$link); $link = ereg_replace('ú','u',$link); I ask if is a way to make those lines into a single one but working as well as this piece. I'm thinking in increase those lines so will be wonderful if I can optimize the code.$map = array ( 'ñ', 'n', 'á', 'a', 'é', 'e', 'í', 'i', 'ó', 'o', 'ú', 'u',
-- Jim Lucas "Perseverance is not a long race; it is many short races one after the other" Walter Elliot "Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them." Twelfth Night, Act II, Scene V by William Shakespeare);$link = str_replace( array_keys( $map ), array_values( $map ), $link );?> The only way to make it faster is to build the key array and value array separately, but then the association is not so clear. Cheers, Rob.