473,378 Members | 1,658 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Find minimum and maximum value with loop

Expand|Select|Wrap|Line Numbers
  1. array = array(
  2.         array(48,72,13,14,15),
  3.         array(21,22,53,24,75),
  4.         array(31,57,33,34,35),
  5.         array(41,95,43,44,45),
  6.         array(59,52,53,54,55),
  7.         array(61,69,63,64,65)
  8.  
  9. );
  10.  
  11. $high = 0;// highest value
  12. $low = 100;// lowest value
  13. for ($row = 0; $row < count($array); $row++)
  14. { //find highest value
  15.     for ($col = 0; $col < count($array); $col++)
  16.     {
  17.         if ($array[$row][$col] > $high)
  18.         {
  19.             $high = $array[$row][$col];
  20.         }
  21.     }
  22. }
  23. for ($r = 1; $r < count($array); $r++)
  24. { //find lowest value
  25.     for ($c = 1; $c < count($array); $c++){
  26.         if ($array[$r][$c] < $low){
  27.             $low = $array[$r][$c];
  28.         }
  29.     }
  30. }
  31.  
  32.  
  33. echo $low;
  34. echo $high;
Nov 16 '15 #1
1 1043
Rabbit
12,516 Expert Mod 8TB
Please use code tags when posting code or formatted data.

What's your question? You haven't asked anything and you haven't posted any error messages you're getting.
Nov 16 '15 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Roger Withnell | last post by:
How do I find the maximum value of a recordset column? I'd rather do it this way than open a new recordset with Max(column). Thanks in anticipation. Posted Via Usenet.com Premium Usenet...
5
by: Sunny123 | last post by:
hello i am trying to find the maximum value of a function and where it occur. i.e there is an array x |y ============= | |
29
by: garyusenet | last post by:
I'm trying to investigate the maximum size of different variable types. I'm using INT as my starting variable for exploration. I know that the maximum number that the int variable can take is:...
3
by: Madmartigan | last post by:
Hello I have the following task but am battling with the final output. How do I keep two different vectors in sync and how would I retrieve the index for the maximum value of one of the vectors??...
2
by: Pugi! | last post by:
hi, I am using this code for checking wether a value (form input) is an integer and wether it is smaller than a given maximum and greater then a given minimum value: function...
1
by: argniw | last post by:
I need a stored procedure or other method to find the maximum value for each set of records. I would want to eliminate all of the non- maximum records. An example of the data is below. For the...
2
choke
by: choke | last post by:
I need to write a function in devc++ that creates an array of n integers, each element is equal to n*n+i*i-n*i where i is from 0 to n-1 as the array index. Within the same function I need to find...
1
by: maurizio | last post by:
thank you for your answer actually i've to do some statistics (maximum,minimum,mean,standard deviation,....) of a file of data in which each column is a particular type of data. (the file is a tab...
8
by: omar999 | last post by:
i can a max value of a single column with where clause like this select MAX(Price_Band_1) AS HighestPrice from UK_Specials where ID IN (1,3,5,7,9,10,13,15,17,19,21,23,25,27,29,31,33,35,37) ...
1
by: Dleary4395 | last post by:
Hello, my question is how to find the minimum value of a set of numbers in a loop. I used a for loop, and the maximum value is always right but the minimum is always 0. I think it's because the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.