S
S
sunnyrio2018-04-14 10:35:49
PHP
sunnyrio, 2018-04-14 10:35:49

How to find the maximum element of an array?

How to find out which of the elements 100, 75, 50, 25 has the greatest value and how to work with this element and its components in the future? In general, did I collect a three-dimensional array correctly?
the code:

$k = 0;
  for ($i = 0; $i <= $arr1; $i++)
    {
      for ($j = 0; $j <= $arr2; $j++)
        {				
          if ($arr_so[$i][1] == $arr_sr[$j][1])
            {
              if ($arr_so[$i][9] == $arr_sr[$j][7]) $arr_find['100'][$k] = $arr_so[$i];
              if ($arr_so[$i][11] == $arr_sr[$j][9]) $arr_find['75'][$k] = $arr_so[$i];
              echo $arr_find['100'][$k][0];
              echo $arr_find['75'][$k][0];							
            };
          if ($arr_so[$i][10] == $arr_sr[$j][9])
            {
              if ($arr_so[$i][9] == $arr_sr[$j][7]) $arr_find['50'][$k] = $arr_so[$i];
              if ($arr_so[$i][11] == $arr_sr[$j][9]) $arr_find['25'][$k] = $arr_so[$i];
              echo $arr_find['50'][$k][0];
              echo $arr_find['25'][$k][0];	
            };
          $k++;
        };
    };

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel Kornilov, 2018-04-14
@KorniloFF

var max = Math.max.apply(null,[100, 75, 50, 25]);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question