Antwort: [PHP] Replacing first character in a string

From: Date: Wed, 30 Apr 2003 20:08:13 +0000
Subject: Antwort: [PHP] Replacing first character in a string
Groups: php.general 
Request: Send a blank email to php-general+get-145852@lists.php.net to get a copy of this message
Hi, try this, if ... { $rawPOINTS = substr($rawPOINTS,1,strlen($rawPOINTS)-1); } That should work :) =============================================== Thomas Sinka mobil: +49 163 3 23 12 72 mailto: thomas.sinka@it-choice.de An: PHP <php-general@lists.php.net> Kopie: Blindkopie: Thema: [PHP] Replacing first character in a string @ 30.04.2003 14:03 CST <font size=-1></font> 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.php

« previous php.general (#145852) next »