A beginner asks a simple logic-related question.

Source: Internet
Author: User
Cainiao asked me a simple logic question. I want to implement the 62 hexadecimal function. However, the following code can only be returned and cannot be returned. I don't know why, function & nbsp; dwz ($ id, $ str = "") {$ a = array ("0", "1", "2", "3 ", "4", "5", "6", "7", "8", "9. Cainiao asks a simple logic question.
I want to implement the 62 hexadecimal function, but the following code can only be echo and cannot be returned. I don't know why.


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 ($ ));
$ Xs = $ id % sizeof ($ );
If ($ zs> = sizeof ($ )){
$ Str = $ a [$ xs]. $ str;
Dwz ($ zs, $ str );
}
Else {
If ($ str = ""){
Return $ a [$ zs]. $ a [$ xs];
}
Else {
Echo $ a [$ zs]. $ str; // output only
Return $ a [$ zs]. $ str; // no value is returned. I don't know why
}
}
}
For ($ I = 999990; $ I <= 1000000; $ I ++ ){
Echo dwz ($ I );
Echo"
";
}
Logic Cainiao:
------ Solution --------------------
Row 3 dwz ($ zs, $ str );
No response
$ Str = dwz ($ zs, $ str );

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

------ Solution --------------------

If ($ zs> = sizeof ($ )){
$ Str = $ a [$ xs]. $ str;
Dwz ($ zs, $ str); // add return: return dwz ($ zs, $ str) here );
}
 

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.