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!

easy variable change

Status
Not open for further replies.

lvennard

MIS
Apr 20, 2000
93
US
I cant remeber how to do this but i've done it before in PHP.

I want to take off the last charater of a value, like the perl chomp/chop function.

$a = 75%;
$rawvalue = rtrim ($a, "%");

NOW $rawvalue should equal "75" right? but it doesnt work.

how do I chop off the last character of the variable?
 
I'm guessing it's some silly typo or some such, maybe post your actual code and we can all look, because you have it exactly right. In fact, below I've cut and pasted a script which works exactly as you described... I just typed in what you posted above.

<?

$a = &quot;75%&quot;;
$raw = rtrim($a, &quot;%&quot;);

echo $raw;
?>

 
note that the first script does not have the quotes around the percent sign... Bastien

There are many ways to skin this cat,
but it still tastes like chicken
 
here is the actual code.
$procidle ends up as a ##% value

echo &quot;<tr><td>\n&quot;;
echo &quot;<font size=$serverinfofont>\n&quot;;
echo &quot;Processor Usage:  \n&quot;;
$procidle = `/bin/sysinfo --system | grep &quot;System load&quot; | awk '{print $12 }'`;
$checkprochigh = rtrim ($procidle, &quot;%&quot;);
$prockinuse = (100-$checkprochigh);
//echo &quot;$procinuse\n&quot;;
echo &quot;$checkprochigh&quot;;
if ($checkprochigh >= 90) {
echo &quot; \n&quot;;
echo &quot;<a href=\&quot;$whysohighprocurl\&quot; target=right>\n&quot;;
echo &quot;why so high?</a>\n&quot;;
}
echo &quot;</font>\n&quot;;
echo &quot;</td></tr>\n&quot;;
 
i had $procuse comment out so that it would still look like it was working.
 
$rawvalue = substr ($a, 0, -1)

worked great!

Thanks Everyone!!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top