Write a PHP program to create a new string of the first half of a given string of even length

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

Write a PHP program to create a new string of the first half of a given string of even length.

الأجوبة

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

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

Sample Output:

He
H
هل كان المحتوى مفيد؟

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

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