Need some help with Numbers in PHP -


i'm having little problem numbers in php, i'm trying do:

$uni number in question , 1 need work (it doesn't matter number can in hundreds of thousands or 5).

i'm trying work out how many times "100" can go into $uni, that's not problem, problem need remainding number (after decimal point) formatted.

for example:

(just working numbers on 100)

if have $uni "356" need output "3 credits" ($credearned = 3;) & "56" ($per = 56;) left over.

also, need strip numbers if $per "05" has "5".

$uni = 190; if($uni >101){ $credearned = $uni / 100; $per = ; }else{ $credearned = 0; $per = $uni; } 

i'd appreciate help, , hope explanation wasn't confusing.

thanks.

this % (modulus) operator for, finding remainder of 1 number divided another:

echo 356 % 100; // 56 

in case, can find "credits" , "left over" in couple of simple statements instead of complex loop:

$uni = 190; $credits = (int)($uni / 100); // 1 $left_over = $uni % 100;      // 90 

this works numbers 05; you'll 0 $credits , 5 $left_over.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -