Write a PHP program which reads a text (only alphabetical characters and spaces.) and prints two words
- برمجة بي اتش بي
- 2021-09-08
- mhanasmh00489829403
الأجوبة
<?php
$str = trim(fgets(STDIN));
$arr = explode(' ', $str);
$arr2 = array_count_values($arr);
$word1 = array_search(max($arr2), $arr2);
$word2 = '';
foreach ($arr as $s) {
if (strlen($s) > strlen($word2)) {
$word2 = $s;
}
}
printf("%s %s\n", $word1, $word2);
?>
Sample Input:
Thank you for your comment and your participation.
Sample Output:
your participation.
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال