Write a PHP program to concat two given strings. If the given strings have different length remove the characters from the longer string
- برمجة بي اتش بي
- 2021-09-08
- mhanasmh00489829403
الأجوبة
<?php
function test($s1, $s2)
{
if (strlen($s1) < strlen($s2))
{
return $s1 . substr($s2, strlen($s2) - strlen($s1));
}
else if (strlen($s1) > strlen($s2))
{
return substr($s1, strlen($s1) - strlen($s2)) . $s2;
}
else
{
return $s1 . $s2;
}
}
echo test("abc", "abcd") . "\n";
echo test("Python", "Python") . "\n";
echo test("JS", "Python") . "\n";
Sample Output:
abcbcd PythonPython JSon
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال