comparing a array:
I have
$array = array (
array ( number => "1", class => "" ),
array ( number => "1", class => "" ), array ( number => "2", class => "" ),
array ( number => "4", class => "" ),
array ( number => "3", class => "" ) );
And now I need to compare each "number" value with eachother.
What I want to do is compared them all and see if there are pairs of numbers.
First I did a
sort ( $array );
As I expect it to be simpler if all equal values are together.
Now I'm thinking of looping trough the positions from 0 to count ( $array ) and if'ing the thing.
I would do
if ( $array[$i][number] ==array[$i+1][number] ){
// first and second are equal lets go on
if ( $array[$i+1][number]==$array[$i+2][number]) {
}
}
But I dont think thats a nice thing, since I would if $i+x everytime.
a btter alg to do this?