PHP get maximum value from multidimensional array; Through this tutorial, i am going to show you how to get or find maximum or highest value from multidimensional array in PHP.
PHP Get Maximum Value in Multidimensional Array
Let’s take multiple examples to get max or highest value from multidimensional array in PHP using For Loop, forEach Loop; is as follows:
- PHP Get Highest Value in Multidimensional Array using ForEach Loop
- PHP Find Max/Largest Value in Multidimensional Array using For Loop
PHP Get Highest Value in Multidimensional Array using ForEach Loop
Let’s see the below given example to get the highest Value form multidimensional array using foreach loop in PHP; is as follows:
<?php //get the highest value from multi dimenstion array in php $array = [[100, 200, 600],[205, 108, 849, 456],[548, 149, 784]]; $max = 0; foreach ($array as $val) { foreach($val as $key=>$val1) { if ($val1 > $max) { $max = $val1; } } } print ($max); ?>
PHP Find Max/Largest Value in Multidimensional Array using For Loop
Let’s see the below given example to get the highest Value form multidimensional array using for loop in PHP; is as follows:
<?php //get the max value from multi dimenstion array in php $array = [[100, 200, 600],[205, 108, 849, 456],[548, 149, 7840]]; $max = 0; for($i=0;$i<count($array);$i++) { for($j=0;$j<count($array[$i]);$j++) { if ($array[$i][$j] > $max) { $max = $array[$i][$j]; } } } print $max; ?>
Recommended PHP Tutorials
Recommended:-How to Insert Data Into Database in PHP using Xampp
Recommended:-How to Fetch Single Row Data From Database in PHP
Recommended:-How to Display Data From Database in PHP using Id
Recommended:-How to Update Data From Database in PHP
Recommended:-CRUD Operations in PHP MySQL with Bootstrap
Recommended:-PHP MySQL Ajax Add Edit Delete Same Page
Recommended:-PHP Ajax Live Search From MySQL Database
Recommended:-PHP MySQL Ajax Autocomplete TextBox From DB Example
Recommended:-Form validation using jQuery in PHP
Recommended:-PHP + MySQL Login Form with Session
Recommended:-PHP + MySQL Registration Form with Validation
Recommended:-PHP Ajax Form Submit with Validation Example
Recommended:-Ajax Get Data From MySQL Database in PHP
Recommended:-Google Places Autocomplete in PHP
Recommended:-PHP + MySQL + jQuery Signature Pad
Recommended:-Country State City Dropdown in PHP + MySQL + Ajax
Recommended:-PHP Send Reset Password Link Email
Recommended:-Star Rating System In PHP + MySQL + Ajax
Recommended:-Category Subcategory Dropdown in PHP + MySQL + Ajax
Recommended:-PHP + Ajax Upload Multiple Image with Preview
Recommended:-PHP Upload File to AWS S3 Bucket
Recommended:-Import CSV File Into MySQL Database using PHP
Recommended:-PHP + Ajax Import CSV File Into MySQL Database
Recommended:-PHP + MySQL Login and Registration Form using XAMPP
Recommended:-Import json File Data Into MySQL Database in PHP
Recommended:-PHP Subtract Days, Month, Year From Date
Recommended:-PHP Add Days, Month, Year From Date
Recommended:-How to change max file upload size in php ini Ubuntu
Recommended:-How to Get Next Day, Month, Year From Date In Php
Recommended:-How to Convert a String Into Array in PHP
Recommended:-Get Minimum Value From Array PHP
Recommended:-How to Remove Special Character from String in PHP
Recommended:-Get Max Value From Array in PHP