How to swap two numbers without using a temporary variable ? | PHP code to swap using XOR ; Code to swap ' x ' ( 1010 ) and ' y ' ( 0101 ) x now becomes 15 ( 1111 ) ; y becomes 10 ( 1010 ) ; x becomes 5 ( 0101 )
< ? php $ x = 10 ; $ y = 5 ; $ x = $ x ^ $ y ; $ y = $ x ^ $ y ; $ x = $ x ^ $ y ; echo " After ▁ Swapping : ▁ x ▁ = ▁ " , $ x , " , ▁ " , " y ▁ = ▁ " , $ y ; ? >