Write a PHP program to create a new string using the two middle characters of a given string of even length (at least 2)

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

Write a PHP program to create a new string using the two middle characters of a given string of even length (at least 2).

الأجوبة

<?php
function test($s1)
{ 
 
  return substr($s1, strlen($s1)/2 - 1, 2); 

}

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

Sample Output:

el
JS
هل كان المحتوى مفيد؟

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

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