Remove First Character In A String

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
jwalsh
Forum Contributor
Posts: 202
Joined: Sat Jan 03, 2004 4:55 pm
Location: Cleveland, OH

Remove First Character In A String

Post by jwalsh »

Hi,

I have code that returns the following string..

:3:5:2:5

and I need to trim off the first : so it says

3:5:2:5

is there an easy way to do this?

Thanks,

Josh
User avatar
jwalsh
Forum Contributor
Posts: 202
Joined: Sat Jan 03, 2004 4:55 pm
Location: Cleveland, OH

Post by jwalsh »

Got it working this way...


Code: Select all

$string = &quote;:3:4:6:3:5&quote;;
$length = (strlen($string) - 1);
echo substr_replace($string, '', 0, '-' .$length);
Is this best?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

close

Code: Select all

$string = ":3:4:6:3:5";
echo substr($string, 1);    // 3:4:6:3:5
Post Reply