Write a PHP program to create a new string with the last char added at the front and back of a given string of length 1 or more

  • برمجة بي اتش بي

Write a PHP program to create a new string with the last char added at the front and back of a given string of length 1 or more.

 

الأجوبة

<?php
function test($str) 
{
   $s = substr($str, strlen($str) - 1);
      return $s.$str.$s;
   
}

echo test("Red")."\n";
echo test("Green")."\n";
echo test("1")."\n";

Sample Output:

dRedd
nGreenn
111
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...