[Solved] If and If
Posted: Tue Sep 08, 2009 12:25 am
Hey there, I am trying to make an Auto bytes converter, so it won't display the size as 45278489 [bytes] but as 45.278 MB.
The math part works flawless, but I got a problem with the IF statements...
I tried like 7 different ways to write it and none worked.
My most recent try:
I also tried stuff like
Most of my tries worked [No errors] but they didn't work as I wanted them to. (The way I wanted them to work is in the complete tagged code [not the last one, the one before.] which is pretty self explanatory), they just ignored the other else if's, and used the $filesizecalc and $filesizebyte setting of the first one...
I think I know a way to make it work, but that way is going to be really a pain to read and understand, and also pretty much double the size of the file, and make it messy...
I really appreciate any help, even if you say you don't know
Oh, and sorry for the bad English, I just woke up after a whole night working on this, and my brain is still kinda numb...
The math part works flawless, but I got a problem with the IF statements...
I tried like 7 different ways to write it and none worked.
My most recent try:
Code: Select all
if($filesize <= "500000000") and if($filesize > "999999")
{
$filesizecalc = (round($filesize / 1000) / 1000);
$filesizebyte = "MB";
}
else if($filesize <= "1000000") and if($filesize > "999")
{
$filesizecalc = ($filesize / 1000);
$filesizebyte = "KB";
}Code: Select all
if("999999" <= $filesize <= "500000000")I think I know a way to make it work, but that way is going to be really a pain to read and understand, and also pretty much double the size of the file, and make it messy...
I really appreciate any help, even if you say you don't know
Oh, and sorry for the bad English, I just woke up after a whole night working on this, and my brain is still kinda numb...