Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove from right

Status
Not open for further replies.

JamesManke

Programmer
Jul 1, 2004
54
0
0
CA
Hi there, How would I remove the first 2 numbers of a string?
Example - 33789 would be 789

Thanks for your help,

James
 
$x = Substr('33789',2,3);
//$x now equals '789'.
The 2 is where to start looking in the string. (The first character is # 0 ). The 3 is how many characters to look at.
 
Code:
$num = '337895235';

$trimmed = substr($num, 2);

echo $trimmed;

Ommitting the 3rd argument will make it such that it returns all but the first two characters.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top