Im not sure the correct syntax to solve this problem.

I have 3 arrays:

A=(3, 4, 5)
B=(1, 3, 5)
C=(5, 3, 2)

I'd like to loop through first element of each array and find the largest int, move to the 2nd element of each array and again find the largest and so forth.

Any suggestions would be apreciated.

<?php
function sort($arr)
{
	for($i=0;$i<count($arr);$i++)
	{
		if($arr[$i]>$arr[$i+1])
		{
			$max=$arr[$i+1];
			$arr[$i+1]=$arr[$i];
			$arr[$i]=$max;						
		}
	}
	return ($arr);
}

$a[0]=3;
$a[1]=4;
$a[2]=5;

$b[0]=1;
$b[1]=3;
$b[2]=5;

$c[0]=5;
$c[1]=3;
$c[2]=2;

$a=sort($a);
$b=sort($b);
$c=sort($c);

?>

Thank you. Thats much apreciated.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.