Swap Two Numbers In PHP

📔 : PHP 🔗
Copy Fullscreen Close Fullscreen
<?php
  $no1 = 90;
  $no2 = 100;
  //define another variable then change values.
  $temp = $no1;
  echo "Before swap :<br/>no1=$no1, no2=$no2";
  $no1 = $no2;
  $no2 = $temp;
  echo "<br/> After swap :<br/>no1=$no1, no2=$no2";
?>
Output
Before swap :
no1=90, no2=100
After swap :
no1=100, no2=90

Related Topics :

Rahul Kumar

Rahul Kumar

Hi ! My name is Rahul Kumar Rajput. I'm a back end web developer and founder of learnhindituts.com. I live in Uttar Pradesh (UP), India and I love to talk about programming as well as writing technical tutorials and tips that can help to others.

Get connected with me. :) LinkedIn Twitter Instagram Facebook