Rookie ask a simple logic question, seek answers

Source: Internet
Author: User
Logic rookie, simple.

I want to achieve 62 of the functionality of the system, but the following code can only echo out, can not return, do not know what is the reason, seek expert answers

function DWZ ($id, $str = "") {$a =array ("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "s", "T", "U", "V", "w", "X", "Y", "Z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K" "," L "," M "," N "," O "," P "," Q "," R "," S "," T "," U "," V "," W "," X "," Y "," Z "), $zs = (int) ($id/sizeof ($a)), $xs = $id%sizeof ($a); ($zs >=sizeof ($a)) {$str = $a [$xs]. $str;d wz ($zs, $str);} Else{if ($str = = "") {return $a [$zs]. $a [$xs];} Else{echo   $a [$zs]. $str;//This can only output return $a [$zs]. $str;//Return no value, do not know what reason}}}for ($i =999990; $i <=1000000; $i + +) {Echo DWZ ($i); echo "
";}


Reply to discussion (solution)

Line 7th DWZ ($zs, $STR);
did not undertake to return
$str = DWZ ($zs, $STR);

Return $STR is also required at the end of the function;

    if ($zs >=sizeof ($a)) {         $str = $a [$xs]. $str;         DWZ ($zs, $STR); Join Return:return DWZ here ($zs, $STR);    

Line 7th DWZ ($zs, $STR);
did not undertake to return
$str = DWZ ($zs, $STR);

Return $STR is also required at the end of the function;

Haha, yes, thank you for your reminding and guidance.

This can also be written, reversible front unlimited length

echo convert_62 (999990); 4c8secho convert_62 (' 4c8s ', 1); 999990function convert_62 ($s, $mode =0) {$d = Str_split ('  0123456789ABCDEFGHIJKLMNOPQRSTUVEXYZabcdefghijklmnopqrstuvwxyz ');  $r = ";    if ($mode) {$d = Array_flip ($d); for ($i =0; $i
  
  

This can also be written, reversible front unlimited length

echo convert_62 (999990); 4c8secho convert_62 (' 4c8s ', 1); 999990function convert_62 ($s, $mode =0) {$d = Str_split ('  0123456789ABCDEFGHIJKLMNOPQRSTUVEXYZabcdefghijklmnopqrstuvwxyz ');  $r = ";    if ($mode) {$d = Array_flip ($d); for ($i =0; $i
     
    
Thanks, thank you.

This can also be written, reversible front unlimited length

echo convert_62 (999990); 4c8secho convert_62 (' 4c8s ', 1); 999990function convert_62 ($s, $mode =0) {$d = Str_split ('  0123456789ABCDEFGHIJKLMNOPQRSTUVEXYZabcdefghijklmnopqrstuvwxyz ');  $r = ";    if ($mode) {$d = Array_flip ($d); for ($i =0; $i
       
      

Excuse me, I ask why I put this file in the local test can be used, but placed on the server is not available, will be prompted to find bcmod this function

Well, this is why the PHP_BC extension is not loaded (PHP for win is automatically loaded)
You can also check to see if the PHP_GMP extension is loaded, as is the case with this library.

Well, this is why the PHP_BC extension is not loaded (PHP for win is automatically loaded)
You can also check to see if the PHP_GMP extension is loaded, as is the case with this library.

Really did not load, then how to do?
I don't have permissions on the server.

Print_r (Get_loaded_extensions ());
Let's see what we got.

Print_r (Get_loaded_extensions ());
Let's see what we got.

Array (    [0] = date    [1] = Libxml    [2] = = OpenSSL    [3] = Pcre    [4] = Zlib    [5] = C Type    [6] = Curl    [7] = Dom    [8] = + Filter    [9] = FTP    [ten] = GD    [one] = hash
        [12] = Iconv    [+] + JSON    [+] = mbstring    [[] = MCrypt    [+] = Mhash    [17 ] = MySQL [+    ]-SimpleXML    [[+] = SPL    [] = PDO    [+] = POSIX    [] = REFL ection [[] = [[]] = [+]    = pdo_sqlite [+] = sockets [+    ]    = SQLite [27] = > Standard    [tokenizer] + = [+] +    XML [+]    = XmlReader    [+] = XmlWriter    [ [+] = Zip    [+] = Apache2handler [+]    = memcache    [+] = MSSQL    [+] = Soap    [ PNS] = Zend Optimizer)

It's hard to do without permission.
Just write it yourself, didn't you?

It's hard to do without permission.
Just write it yourself, didn't you?

I wrote that mistake, found that the operation is wrong on the back, and then use your
Still can't figure out where my mistake is, why it's wrong to do it in the back
God, help me see it.

function DWZ ($id, $str = "") {$a =array ("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "s", "T", "U", "V", "w", "X", "Y", "Z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K" "," L "," M "," N "," O "," P "," Q "," R "," S "," T "," U "," V "," W "," X "," Y "," Z "), $zs = (int) ($id/sizeof ($a)), $xs = $id%sizeof ($a); ($zs >=sizeof ($a)) {$str = $a [$xs]. $str; $str =dwz ($zs, $str);} Else{if ($str = = "") {return $a [$zs]. $a [$xs];} Else{return $a [$zs]. $str;}} return $STR;}


This is I based on your tips to change, can be displayed, but my previous algorithm is wrong, help to see

Finally, thank you, great God.

function DWZ ($s) {  $d = str_split (' 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVEXYZ ');  $r = ";  while ($s) {$r = $d [(int) ($s%62)]. $r; $s = (int) ($s/62);  }  return $r;}
  • 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.