Write a PHP program to create a new string from a given string. If the two characters of the given string from its beginning and end are same return the given string without the first two characters otherwise return the original string
- برمجة بي اتش بي
- 2021-09-08
- mhanasmh00489829403
الأجوبة
<?php
function test($s1)
{
if (strlen($s1) > 1 && substr($s1, 0, 2) == substr($s1, strlen($s1) - 2))
{
return substr($s1, 2);
}
else
{
return $s1;
}
}
echo test("abcab") . "\n";
echo test("Python") . "\n";
Sample Output:
cab Python
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال