Created
April 26, 2022 16:38
-
-
Save kangmasjuqi/1bf7c4c64d7504ace7b7c88d4c89b947 to your computer and use it in GitHub Desktop.
swap 2 numeric values without additional variable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$x = 17; // whatever integer you want | |
$y = 52; // whatever integer you want | |
echo "x : $x\n"; | |
echo "y : $y\n"; | |
$x = $x + $y; | |
$y = $x - $y; | |
$x = $x - $y; | |
echo "x : $x\n"; | |
echo "y : $y\n"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment