如何回显爆炸阵列线

Here's the code.

<!DOCTYPE html>
<html>
<head><title>Numbers</title></head>
<body>
<form action="index.php" method="get">
<b>Numbers</b>
<br>
<textarea rows="12" cols="25" name="result" value="result"></textarea>
<br>
<input type="submit" value="Submit" name="submit">
</form>
</body>
</html>

<?php
$result=$_GET["result"];
if (empty($_GET['result']))
{
echo '<p><font size="3" color="red">Field is Empty*</font></p>';
}
elseif (isset($_GET['result']))
{
$result=(explode("
", $result));
}
{
echo count ($result);
echo "<br />";
echo array_sum($result);
}
?>

Ok so I figured out how to get most of my assignment's tasks and the last 1 that I am stuck with is using similar codes such as filter_var to print out non-numerical values that are submitted. Ex. a b c * & ! @

PRINTING any invalid inputs that aren't numbers. Ex. Letters, symbols.

Any suggestions?

you can use the below code on your $result array & get the desired results:

$oddArray = array();
$evenArray = array();
$skippedArray = array();

    foreach($result as $value)
   {
        if(is_numeric($value))
        {
           if($value%2 == 0)
           {
               $evenArray[] = $value;
           }
           else
           {
               $oddArray[] = $value; 
           }     
        }
        else
        {
            $skippedArray[] = $value;
        }   
} 

echo "Sum of odd values entered: ".array_sum($oddArray);
echo "Sum of even values entered: ".array_sum($evenArray);
echo "Skipped invalid values entered: ";
print_r($skippedArray);

I hope above will help you.