You are here: Re: Change alternate commas to semi colons... « PHP Programming Language « IT news, forums, messages
Re: Change alternate commas to semi colons...

Posted by Malcolm Dew-Jones on 06/20/06 22:10

Rik (luiheidsgoeroe@hotmail.com) wrote:
: StevePBurgess@gmail.com wrote:
: > With a string of authors such as:
: >
: > Carson, David, Milne, Rebecca, Pakes, Francis J., Shalev, Karen,
: > Shawyer, Andrea
: >
: > I would like to write a function to change every other comma into a
: > semi colon (thereby defining where one name ends and the next begins).
: >
: > I could do it by writing a complex (and slow) procedure - but is there
: > a quick way of doing it using regular expressions, for example?


: Regular expressions can be used, I'd think this is faster:

I wouldn't assume that a block of php code is faster than simply calling
preg_replace. In fact I wouldn't be surprised if it's the other way round
- preg_replace may be faster.

preg_replace maps to a function written in C that does some string
manipulations (all code written in C). All php does internally is to set
up the parameters and call that underlying function.

The block of php code, on the other hand, maps to a whole bunch of
manipulations of php data structures driven by the php interpretter, each
one of which likely involves setting up parameters and calling some
underlying function to do the work.

I would be interested to see the result of a proper comparison between the
two.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация