Reverse a sting using loop in php

Hi , when I reverse a string using loop in php like
Code
  1. $str="navin";

  2.  $rstr="";

  3.  $len=strlen($str);

  4. for($i=$len-1;$i>=0;$i--)

  5. {

  6. $rstr.=$str[$i];

  7. }

  8. echo $rstr;
Copyright GeekInterview.com

It work but I want to know why we use .dot(.) $rstr.=$str[$i]; over here thanks in advance

Questions by navin3434

Showing Answers 1 - 3 of 3 Answers

Emiliano Gaytan

  • Mar 21st, 2013
 

To concat, . operator concats left & right values; Google it for more info

Code
  1. $myVar = 2; // declare variable in php

  2. print_r($myVar . "<br>");  //print on screen your variable w html brake to next line and using concat . operator

  3. $myVar .= $myVar;  // concat  variable to itself using . operator

  4. print_r($myVar. "<br>");// print as before

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions