大佬教程收集整理的这篇文章主要介绍了php实现将任意进制数转换成10进制的方法,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
本文实例讲述了PHP实现将任意进制数转换成10进制的方法。分享给大家供大家参考。具体如下:
PHP将任意进制的数转换成10进制,例如8进制转换成10进制,16进制转换成10进制
php;"> <>PHP # Show the steps involved in converTing a number # from any base (like octal or heX) to base 10 # See below for examples,instructions and copyright function show_convert_to_base_10 ($number,$basE) { // If the number contains a decimal component if (strstr ($number,'.')) { // Get the Integer and decimal components list ($Integer,$decimal) = explode ('.',$number); } else { // the number is an Integer $Integer = $number; } print "Convert the base $base number $number to a base 10 number:'; if (isset ($decimal)) { print "Convert the decimal component (0.$decimal) of the number:'; } $sums = implode (' + ',$sums); eval ("\$base_10_value = $sums;"); print "The value of the base $base number $number in base 10 is $base_10_value.
"; print "This number is derived from the sum of the values of the prevIoUs operations ($sums).
"; }
以上是大佬教程为你收集整理的php实现将任意进制数转换成10进制的方法全部内容,希望文章能够帮你解决php实现将任意进制数转换成10进制的方法所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。