Strip off "%" from a string
Posted: Mon Sep 17, 2007 4:18 pm
Code: Select all
$variable1 = 100%A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
$variable1 = 100%Code: Select all
$variable1 = trim($variable1, '%');Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I have a little bit of problem hereCode: Select all
$score1file = "../data/df/score1";
$score1open = fopen($score1file, 'r');
$score1 = fread($score1open, filesize($score1file));
fclose($score1open);
if (trim($dfsplitdata[4], '%') >= $score1 ) {
....condition
}Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]Code: Select all
tags, not [syntax=php]tags, when posting PHP code.
2) PHP is lazy typed. You don't need to set it as a number. However, you can try [b](int)$score1[/b] if you think it'll help.
3) You first sentence doesn't make sense to me.Code: Select all
$clean_string = str_replace("%","",$my_string_to_search_through);