look at the codes plz $a = '29'; $b = '7'; $c = $a/$b; echo $c; PHP: very simple thing. we divided $a with $b (29 divided by 7) it will show the result : 4.1428571428571428571428571428571 very long...isnt it? well i want it to show just 4.14 that means only two number after the point (.) how can i do this...plz help me
number_format will only give you 4.1428571428571428571428571428571. its not going to make it 4.14. try number_format and the substr to get what you need. Good luck. btw $a = '29'; $b = '7'; $a and $b are strings not integers. you cant divide 2 strings.(lol/haha=) you need $a = 29; $b = 7;
number_format should work fine because I am using it. If you have problem, you can try to round($c*100)/100
tnx niil...that works fine @astrazone: i didnt need to use substr...only number_format works fine. did u try only number_format urself? im confussed if it depends on php version !! btw...strings or integers...whatever...both works fine in php 5.2.9
Sorry I didnt know that anyway you should do it. bad habit if you will use any other language you will get into so much trouble trust me. I dont think that it depends on the php version. http://us3.php.net/manual/en/function.number-format.php