Q:

Write a PHP program to move the last two characters to the start of a given string of length at least two

0

Write a PHP program to move the last two characters to the start of a given string of length at least two.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

<?php
function test($s1)
{ 

  return substr($s1, strlen($s1)-2, 2) . substr($s1, 0, strlen($s1)-2);

}

echo test("Hello")."\n";
echo test("JS")."\n";

Sample Output:

loHel
JS

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now