PHP Custom Multi-method _php instance

Source: Internet
Author: User

The

looks like this:

/** * Custom Multi-system, to get decimal corresponding to the set of the multiple * @param $STR Custom multiple strings * @param $num decimal digits * @return The corresponding number of multiple digits/functio
  N XBin ($str, $num) {$num = Floatval ($num);
  $x = strlen ($STR);
  $arr = Str_split ($STR);
  $digit = Fmod ($num, $x); $xbin = Isset ($arr [$digit])?
  $arr [$digit]: null;
  $pre _digit = Floor ($num/$x);
    if ($pre _digit >= 1) {$pre _digit = XBin ($str, $pre _digit);
  Return $pre _digit. $xbin;
return $xbin;
//Test 8 $str = ' 01234567 ';
$a = XBin ($str, 9);
$b = decoct (9); Dump ($a); String (2) "One" Dump ($b);
String (2) "11"//Test 16 $str = ' 0123456789abcdef ';
$a = XBin ($str, 31);
$b = Dechex (31); Dump ($a); String (2) "1f" Dump ($b);
String (2) "1f"//Custom 30 binary $str = ' 0123456789abcdefghijklmnopqrst ';
$a = XBin ($str, 59); Dump ($a); String (2) "1t"//Custom 92 $STR = ' 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ' ~!@#$%^&* () =
[];\ ',./{}: "<>?\|";
$a = XBin ($str, 183); Dump ($a); String (2) "1|"

The above is a small series for everyone to bring the PHP custom multiple methods of the whole content, I hope that we support cloud-Habitat Community ~

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.