How could I validate the values of the same array, that is, for example:
if ($miarray[0] < $miarray[1])
{
//$miarray[0] toma el valor de $miarray[1]
}
if ($miarray[2] > $miarray[3])
{
//$miarray[3] toma el valor de $miarray[2]
}
//... etcétera...
But the thing is that I have $miarray[n]
, and I do not know how to do it with n
positions.
I was doing it with for
, nothing else I did with 2 for
to see how it worked.
for ($a=0; $a < count($miarray) ; $a++)
{
for ($b=0; $b < count($miarray); $b++) {
if($miarray[$a] > $miarray[$b])
{
$miarray[$b] = $miarray[$a];
}
else
{
$miarray[$a] = $miarray[$b];
}
}
}
Somewhere with these 2 for
choose me the highest and change it, but put the highest value in all $miarray[]
, and what I need is that only put the higher value between $miarray[0]
and $miarray[1]
, after verifying the highest between $miarray[2]
and $miarray[3]
, and so on ...