pacchiee Posted August 11, 2007 Share Posted August 11, 2007 Hello, Can you please let me know how to calculate "the power of" any number in php. For example, say i need to calculate 5 "to the power of" 3. The result should be 5x5x5=125. Thanks in Advance. Link to comment https://forums.phpfreaks.com/topic/64411-solved-calculating-the-power-of-any-number/ Share on other sites More sharing options...
LiamProductions Posted August 11, 2007 Share Posted August 11, 2007 you could do this <?php $thepowerof = " to the power of "; echo "5" . $thepowerof . "3 = " . (5*3); ?> Link to comment https://forums.phpfreaks.com/topic/64411-solved-calculating-the-power-of-any-number/#findComment-321121 Share on other sites More sharing options...
lightningstrike Posted August 11, 2007 Share Posted August 11, 2007 $result = pow(5,3); Link to comment https://forums.phpfreaks.com/topic/64411-solved-calculating-the-power-of-any-number/#findComment-321126 Share on other sites More sharing options...
pacchiee Posted August 11, 2007 Author Share Posted August 11, 2007 Hi, LiamProductions wrote (5*3) which is just multiplying 5 three times giving the result 15. This was not something i was looking at. lightningstrike wrote pow(5,3) - this is what i was exactly looking at! Thanks everybody for the help. Link to comment https://forums.phpfreaks.com/topic/64411-solved-calculating-the-power-of-any-number/#findComment-321128 Share on other sites More sharing options...
LiamProductions Posted August 11, 2007 Share Posted August 11, 2007 Sorry. I thought you ment 5 x 3 but yeah use pow Link to comment https://forums.phpfreaks.com/topic/64411-solved-calculating-the-power-of-any-number/#findComment-321135 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.