Replacing first character in a string
| From: | Lee P. Reilly | Date: | Wed, 30 Apr 2003 20:03:32 +0000 |
| Subject: | Replacing first character in a string | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-145845@lists.php.net to get a copy of this message | ||
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