Write a PHP program to convert the last 3 characters of a given string in upper case. If the length of the string has less than 3 then uppercase all the characters
- برمجة بي اتش بي
- 2021-09-08
- mhanasmh00489829403
الأجوبة
<?php
function test($s)
{
return strlen($s) < 3 ? strtoupper($s) : substr($s, 0, strlen($s) - 3).strtoupper(substr($s, strlen($s) - 3));
}
echo test("Python")."\n";
echo test("Javascript")."\n";
echo test("js")."\n";
echo test("PHP")."\n";
Sample Output:
PytHON JavascrIPT JS PHP
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال