Stormkid wrote:[color=blue]
>
> Hi Group I'm trying to figure out a way that I can take two (two
> dimensional) arrays and avShed and shed, and subtract the matching elements
> in shed from avShed I've pasted the arrays blow from a print_r cmd any
> suggestions would be great. Thanks much Todd
> //avShed array
>
> Array ( [0] => Array ( [dayOfWeek] => 1 [timeInt] => 08:00 ) [1] => Array
> ( [dayOfWeek] => 1 [timeInt] => 08:05 ) [2] => Array ( [dayOfWeek] => 1[/color]
<snip>[color=blue]
> [timeInt] => 16:50 ) [95] => Array ( [dayOfWeek] => 2 [timeInt] => 16:55 ) )
>
> // shed array
> Array ( [0] => Array ( [dayOfWeek] => 1 [timeInt] => 08:00 ) [1] => Array[/color]
<snip>[color=blue]
> [timeInt] => 15:10 ) [19] => Array ( [dayOfWeek] => 2 [timeInt] => 15:15 ) )[/color]
UNTESTED:
foreach($shed as $arr) {
for($i=0;$i<count($avShed);++$i) {
if ($arr[1] == $avShed[$i][1] && $arr[0] == $avShed[$i][0]) {
array_splice($avShed, $i, 1);
$i--; //you may or may not need this
// continue 2; //<-- Uncomment if you only want 1st instance removed
}
}
}
I think this'll work. The $i-- is there in case you have 2 exact duplicates
back-to-back.
Looking back, I'm guessing there's a less cpu-intensive way to do this.
Regards,
Shawn
--
Shawn Wilson
shawn@glassgiant.com http://www.glassgiant.com