Re: Replacing first character in a string

From: Date: Thu, 01 May 2003 03:20:48 +0000
Subject: Re: Replacing first character in a string
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-145888@lists.php.net to get a copy of this message
"Lee P. Reilly" <lreilly@lanl.gov> wrote in message news:3EB02C14.79845983@lanl.gov... > I wonder if anyone can help me? I have a string something like this: > ",.00109863,.00219725,.00329588.... and so on....". > > If the *first character* in the string is a comma (as in the case above) > then I want to replace it with "0,", but I cannot find a way to do it. Of all the replies, only one was correct, and it was pretty obfuscated. Try this: if (substr($str,0,1) == ",") $str = "0" . substr($str,1);

« previous php.general (#145888) next »