Skip to content

Instantly share code, notes, and snippets.

@kangmasjuqi
Created April 26, 2022 16:38
Show Gist options
  • Save kangmasjuqi/1bf7c4c64d7504ace7b7c88d4c89b947 to your computer and use it in GitHub Desktop.
Save kangmasjuqi/1bf7c4c64d7504ace7b7c88d4c89b947 to your computer and use it in GitHub Desktop.
swap 2 numeric values without additional variable
<?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