...

View Full Version : Finding unique values in multidimensional arrays



phill_ridout
08-28-2007, 07:08 PM
say i have the following:




$contact["bob"][1] = "0125"
$contact["bob"][2] = "5442"
$contact["bob"][3] = "4254"
$contact["eric"][1] = "2562"
$contact["eric"][2] = "1423"
$contact["eric"][3] = "1455"
$contact["fred"][1] = "1562"
$contact["fred"][2] = "0234"
$contact["fred"][3] = "2234"
$contact["dick"][1] = "0114"
$contact["dick"][2] = "8845"
$contact["dick"][3] = "1455"


how would i create a function that would look through each array and find the different values, in $contact[][3] ?

Mwnciau
08-28-2007, 08:08 PM
foreach ($contact as $key => $value){
$newarray[] = $value[3];
}

$newarray = array_unique($newarray);

phill_ridout
08-28-2007, 09:23 PM
sorted, thanks for that



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum