RE: [PHP] Replacing a space with an underscore

From: Date: Thu, 01 May 2003 13:30:47 +0000
Subject: RE: [PHP] Replacing a space with an underscore
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-145949@lists.php.net to get a copy of this message
> > What I would like to do... > > I would like to have either MySql or PHP replace a space with an > underscore > > from a MySql query. Any ideas on how to do that? > > str_replace() > preg_replace() > ereg_replace() > > all fit the bill and will do what you need. But you SHOULD use str_replace()... Using regular expressions for a simple replace like this is a waste of resources. In general, you should always benchmark your solutions. Just because something is a single line of code in a regular expression, a couple lines of individual str_replace()es might be faster. Been there, seen that. :) ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/

« previous php.general (#145949) next »