![]() |
Given 3 numbers, find the largest number among the three numbers. If the first number is greater than the second and third, print it as the greatest. Otherwise, compare the second and third numbers and print the greater one. For Instance, Consider the below example where the value of z is greater than the value of x and the value of y. Input: x = 12, y = 7, z = 15 Table of Content Using the max( ) FunctionThe max() function of PHP is used to find the numerically maximum value in an array or the numerically maximum value of several specified values. Here, we will use the max() function for easily find out the largest number among the three numbers. Example: In this example, we will see how to find largest number in PHP among three numbers by using max function. PHP
Output
The largest number among three is: 15 Using Sorting MethodThe sort() function is an inbuilt function in PHP and is used to sort an array in ascending order i.e, smaller to greater. In this method, first all the three numbers are stored in the array after that it is sorted in increasing order by using sort ( ) function of PHP. Example: In this example, we will see how to find largest number in PHP among three numbers by using sort () function. PHP
Output
The largest number among three is: 15 Using If-else MethodPHP allows us to perform actions based on some type of conditions, or Decision Making that may be logical or comparative. Based on the result of these conditions i.e., either TRUE or FALSE, an action would be performed as asked by the user. In this method, the if statement is used to execute a block of code based on a specified condition. Example: This example illsutrates the finding the Largest Number among three Numbers using the If-Else Condition in PHP. PHP
Output
The largest number is: 15 |
Reffered: https://www.geeksforgeeks.org
PHP |
Related |
---|
![]() |
![]() |
![]() |
![]() |
![]() |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 14 |