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
lexx
Forum Newbie
Posts: 21 Joined: Sat Jun 08, 2002 10:30 pm
Post
by lexx » Fri Jun 21, 2002 9:25 pm
Say I have a string $string="hello==" how do I remove the last two character from the string?
will
Forum Contributor
Posts: 120 Joined: Fri Jun 21, 2002 9:38 am
Location: Memphis, TN
Post
by will » Fri Jun 21, 2002 9:28 pm
Code: Select all
$string = substr($string,0,(strlen($string)-2));
lexx
Forum Newbie
Posts: 21 Joined: Sat Jun 08, 2002 10:30 pm
Post
by lexx » Fri Jun 21, 2002 9:31 pm
how about remove specific character like "=" from the string?
will
Forum Contributor
Posts: 120 Joined: Fri Jun 21, 2002 9:38 am
Location: Memphis, TN
Post
by will » Fri Jun 21, 2002 9:48 pm
Code: Select all
$string = ereg_replace("=","",$string);
Wayne
Forum Contributor
Posts: 339 Joined: Wed Jun 05, 2002 10:59 am
Post
by Wayne » Mon Jun 24, 2002 9:17 am
Code: Select all
$string = str_replace("=", "", $string);
would be more efficient on the server if you are only replacing a specific character such as "=".
twigletmac
Her Royal Site Adminness
Posts: 5371 Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK
Post
by twigletmac » Mon Jun 24, 2002 9:25 am
Code: Select all
$string = substr($string,0,(strlen($string)-2));
This could be simplified to,
Mac