PHP integer and string add-in

Source: Internet
Author: User
There are several kinds of algorithms,
For example: $tr = ' aaaaa '; Turn into 0

$tr = ' A123AA '; Turn into 0
$tr = ' 22aaa ';   Turn into  22

That is, when matched to a string, not shaped, the match continues until the character is encountered and all subsequent transitions to 0are added to the front.

Example 1:

$str = "123stringA";
$str 2 = "123XX797STRINGB";

$result = $str + $str 2; $result = 456 (123+123)

Example 2:

$str = "string123a";
$str 2 = "123XX797STRINGB";

$result = $str + $str 2; $result = 123

According to this principle, to convert a numeric string to a numeric value you can add the original numeric string to a string that is converted to zero when adding (for example: stringABC12321).

Or, add to the number 0! ====> is operated by addition operations!

PHP integer and string add-in

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.