PHP does not use a third variable to exchange the value of 2 variables _php tutorial

Source: Internet
Author: User
I've done it before.Php The interview question is this:Swapping values for two variables without using the third variable . In general, the Third intermediate variable is used to realize the value exchange of the original two variables, but this problem does not require the use of intermediate variables, which for beginners is a problem. Some of the methods found online are summarized as follows:

= "a"= "B"' $a before Exchange: '.. ', $b: '..'
'.==(, 0, (()-(=(,(' After exchange $ A: '.. ', $b: '..'
''-----------------------
'= "a"= "B"' $a before Exchange: '.. ', $b: '..'
'.==(, "",=(, "",' After exchange $ A: '.. ', $b: '..'
''-----------------------
'= "a"= "B"' $a before Exchange: '.. ', $b: '..'
'(,)=(,' After exchange $ A: '.. ', $b: '..'
''-----------------------
'= ' A '= ' B '' $a before Exchange: '.. ', $b: '..'
'=^=^=^' After exchange $ A: '.. ', $b: '..'
''-----------------------
'=3=5' $a before Exchange: '., $b: '. . '
' =+ = - =- ' Exchange $a: '. , $b: '. . '
';

http://www.bkjia.com/phpjc/440328.html www.bkjia.com true Span id= "Isbasedonurl" itemprop= "Isbasedonurl" >http://www.bkjia.com/phpjc/440328.html techarticle ve done a PHP interview question before: The value of two variables is exchanged without the use of a third variable. In general, the Third intermediate variable is used to realize the value exchange of the original two variables ...

  • Related Article

    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.