Re: Replacing first character in a string
| From: | Chester Bullock | Date: | Wed, 30 Apr 2003 20:07:41 +0000 |
| Subject: | Re: Replacing first character in a string | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-145847@lists.php.net to get a copy of this message | ||
Your string is not an array. You need to cut the string down to size, try http://www.php.net/manual/en/function.substr.php , check to see what the first piece is, then act accordingly.
At 02:03 PM 4/30/2003 -0600, you wrote:
Hi there, 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. E.g. say the above string is called $rawPOINTS, what would be in the body of the if loop below to replace the comma? if ($rawPOINTS[0] == ",") { // hmmmm.... } I can think of a few long winded ways of do it, but are there any "one liner" string manipulation functions I can use? I shall look into regular expressions, but if anyone could tell me the solution I'd appreciate it ;-) - Thanks, Lee -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.phpChester Bullock, chester@tenxible.com Tenxible Solutions - Tangible, Flexible Website Hosting, Design and Marketing http://www.tenxible.com ------------------------------------------------------------------------ Do you really own your domain name? Find out with our free domain name research report. http://www.tenxible.com