Originally posted by OhLordy
<?
//splits the string on the % symbol and puts the stuff either side in different elements of an array
$temp_array=explode('%',$freedisk);
//Does the same but on the [space] symbol
$temp_array_two=explode(' ',$temp_array[0]);
//takes the last element of temp_array_two and puts it in freedisk and adds a % on the end
$freedisk=$temp_array_two[(count($temp_array_two)-1)]."%";
?>
Hope this helps
Rob [/B]
Thank you! Yes I understand (the solution is behind explode and
arrays .)
Meanwhile I found another solution myself ... (your solution is surely more fast 😉 !
<?
# find array
$systemoutput="/dev/sda2 2.0G 1.6G 310M 84% /usr";
$number = strlen($systemoutput);
echo "systemoutput>> $systemoutput <br>";
$array = explode(" ", $systemoutput);
for ($findarray=0;$findarray<=$number;$findarray++){
# echo "Array > $findarray $array[$findarray] <br>";
if ( ereg("%",$array[$findarray])) {
$perc=$array[$findarray];
}
}
echo $perc;
?>