phptutorials

PHP program to swap two variables without a 3rd variable

In this post, let’s write a simple PHP snippet to swap two variables without using a temporary variable. Basically, we are going to declare two variables x and y and then swap the values of x and y without introducing a 3rd variable.

Sample output of the above program is here,

phpswap

Related Posts

Leave a Reply