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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

chop() as in Perl 1

Status
Not open for further replies.

soundmind

Technical User
Joined
Jun 30, 2003
Messages
16
Location
US
Hi,

In Perl, the chop() function removes the last character of the string. I'm looking for a function in PHP that does that.

Could you please help me?

I'm getting my data from the database but it's in 4 digits - I only want the last two. Is there a function to do this or do I have to create one that will work. Even then I have no clue.


Thanks!
 
jstreich
The PHP manual says:
Note: chop() is different than the Perl chop() function, which removes the last character in the string.

soundmind
The PHP chop() function is what chomp() is in PERL.
To get a 2 charachters from the right:
Code:
$foo = substr($foo, 0, -1);


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top