Get the App
SLTechnology News&Howtos  ›  Development  › 

Why doesn't php use the third variable to exchange the values of two variables?

Shulou Source: shulou.com Published: 2022-06-03 08:01:00 11月04日 Update

Why does php not use the third variable to exchange the value of two variables? I believe many inexperienced people are at a loss about this. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

Methods: 1. Use "$b=explode ($a ^, $a."); (2) use $b=explode ("| |", $a. "|. $b); $astatum [1]; $barium [0];"; 3, use "list ($b) = array ($b);".

Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer

Php does not use the third variable to exchange the values of two variables

Method 1: use XOR operations

Output result:

Method 2:

Output result:

Method 3:

Output result:

After reading the above, do you understand why php doesn't use the third variable to exchange the values of two variables? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Tags: Variables methods three no two results output content more statements problems helpless for this reason skills tutorials environment computers articles Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Xiaomi Apple MariaDB NVidia