Swapping four variables without temporary variable | PHP program to swap 4 variables without using temporary variable ; swapping a and b variables ; swapping b and c variables ; swapping c and d variables ; initialising variables ; Function call
< ? php function swap ( $ a , $ b , $ c , $ d ) { $ a = $ a + $ b ; $ b = $ a - $ b ; $ a = $ a - $ b ; $ b = $ b + $ c ; $ c = $ b - $ c ; $ b = $ b - $ c ; $ c = $ c + $ d ; $ d = $ c - $ d ; $ c = $ c - $ d ; echo " values ▁ after ▁ swapping ▁ are ▁ : ▁ " , " STRNEWLINE " ; echo " a = " ▁ , ▁ $ a ▁ , " " ; STRNEWLINE TABSYMBOL echo ▁ " b = " ▁ , ▁ $ b ▁ , " " ; STRNEWLINE TABSYMBOL echo ▁ " c = " ▁ , $ c ▁ , " " ; STRNEWLINE TABSYMBOL echo ▁ " d = " ▁ , ▁ $ d ▁ , " " } $ a = 1 ; $ b = 2 ; $ c = 3 ; $ d = 4 ; echo " Values ▁ before ▁ swapping ▁ are ▁ : " , " STRNEWLINE " ; echo " a = " ▁ , ▁ $ a ▁ , " " ; STRNEWLINE TABSYMBOL echo ▁ " b = " ▁ , $ b , " " ; STRNEWLINE TABSYMBOL echo ▁ " c = " ▁ , ▁ $ c ▁ , " " ; STRNEWLINE TABSYMBOL echo ▁ " d = " ▁ , ▁ $ d ▁ , " " , " " swap ( $ a , $ b , $ c , $ d ) ; ? >