Voting

: min(nine, five)?
(Example: nine)

The Note You're Voting On

filipefigueiraf at gmail dot com
4 days ago
<?php

function highAndLow(string $numbers): string {

// Split the input string into an array using spaces as delimiter
// Then filter out any non-numeric values
$numbers = array_filter(explode(" ", $numbers), 'is_numeric');

// Convert the remaining numeric strings to integers
$ints = array_map('intval', $numbers);

// Return the highest and lowest numbers, separated by a space
return max($ints) . " " . min($ints);
}

// Example usage: will output "388 2"
echo(highAndLow(' 2 388 asdfgh 4'));

?>

<< Back to user notes page

To Top