3
21/10/2024 1:34 अपराह्न
विषय प्रारंभकर्ता
- Read an array of integers
- Remove all negative numbers from it and print the remaining elements in reversed order
- In case of no elements left in the array, print "empty"

1 उत्तर
2
21/10/2024 1:35 अपराह्न
My solution:
<?php
$arr = array_map(function ($element) {
return ($element > 0) ? $element : false;
}, explode(" ", readline()));
$arr = array_filter($arr);
$arr = array_reverse($arr);
if (count($arr) > 0) {
echo implode(" ", $arr);
} else {
echo "empty";
}
