PHP program to find out maximum and minimum number in an array

Write a PHP program to find out maximum and minimum number in an array


In this tutorial, you will learn how to find out maximum and minimum number in an array in php

Below is the php script to find out maximum and minimum number in an array in php.

<html>
<head>
    <title>PHP program to find Minimum and Maximum number in an array</title>
</head>
<body>

    <h2>Write a PHP Script to find Minimum and Maximum number in an array</h2>

    <form action="" method="post">
        <input type="text" name="numbers"/> <br>
        <input type="submit"/><br>
    </form>

    <?php
        if( $_POST )
        {  
            $input = $_POST[ 'numbers' ];
            $inputarray = explode(',',$input);

            echo ("The Minimum Number is:".min($inputarray))."<br>";
            echo ("The Maximum Number is:".max($inputarray))."<br>";
        }
    ?>

</body>
</html>


Thanks for reading.

© Copyright - 2018 - 2022 | All rights reserved at Funda of Web IT