Forum Moderators: coopster

Message Too Old, No Replies

compare 2 arrays

         

hugohugo

9:25 pm on Feb 12, 2010 (gmt 0)

10+ Year Member



hey.

I'm sitting with one question. i'm building a gird/schedule form my work.
Well I would like to save the grid/schedule as that first checks if here is no duplication is scheduled afternoon and evening.
Well I have done this as follows:

<?php
$i = 0;
foreach($_POST['Woensdag_Middag_kassa'] as $value) {
$test = $_POST['Woensdag_Avond_service'][$i];
if($value == $test) {
$aErrors[] = "Dubbele naam. Dag Woensdag Functie Kassa / Service";
}
$i++;
}
?>

Well I have a prbleem.
People can have multiple functions, ie do I need this for foreach 5 times carry only the kassa register:
kassa compare buffet
kassa compare service
kassa compare porter
kassa compare buffet
kassa compare club
Then I must also buffet funcites compare with other .. or 5 x 5 foreach loops for 1 days.
This should be 7 times that is 175 days foreach runs only to check.
My question is you here is an easier way before I go typing 1400 lines of code ..

sorry for my bad english

thnx

coopster

1:34 pm on Feb 26, 2010 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, hugohugo.

Have you considered the array functions [php.net], perhaps array_diff() or array_intersect()?