Home > Backend Development > PHP Tutorial > PHP version of arbitrary hexadecimal conversion

PHP version of arbitrary hexadecimal conversion

WBOY
Release: 2016-07-25 08:45:35
Original
1271 people have browsed it
  1.  $int=36; 
  2. $str=array();
  3. $flag=0;
  4. //echo chr($int %36+87);
  5. while($int!=0)
  6. {
  7. if($int%36<=9)$str[$flag++]=$int%36;//36 hexadecimal
  8. else $str[ $flag++]=chr($int%36+87);
  9. $int/=36;
  10. }
  11. for($i=$flag;$i>=0;$i-=1)if($str[$ i]!=0)break;//There are some flaws in the output here. I hope someone can give me some advice (no output when $int=360)
  12. for(;$i>=0;$i-=1)echo $str[$ i];
  13. //echo $str;
  14. ?>
Copy code

php


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template