Hi Rob, It's me again. It's not working, I am afraid. Earlier on I thought everything was OK because I could see visually the intercepts working as it should but what I failed to realize was the values were similar in the other corresponding arrays. Now I have changed the values and I get some really strange things going on. The following is the same array but different values; $rows = array(); $rows[0] = array(10,12,55,26); $rows[1] = array(4,11,34,48); $rows[2] = array(1,20,43,55) ; $rows[3] = array(5,13,14,87); $rows[4] = array(30,42,55,69); $rows[5] = array(18,3,13,70); $rows[6] = array(1,42,43,48); $rows[7] = array(9,11,44,48); $rows[8] = array(3,10,33,55) ; $rows[9] = array(5,10,15,86); $rows[10] = array(10,15,55,69); $rows[11] = array(2,3,17,70); $rows[12] = array(17,11,33,48); $rows[13] = array(10,42,55,69); $rows[14] = array(61,13,23,70); $rows[15] = array(71,12,13,48); $rows[16] = array(9,31,34,38); $rows[17] = array(3,20,13,55) ; $rows[18] = array(5,12,25,87); $rows[19] = array(20,42,55,69); $rows[20] = array(1,4,14,70); As you can see the results are nowhere near what I can see visually. For example a visual view of $rows[0] and $rows[1] would be == 0; $rows[0] and $rows[2] == 55; $rows[0] and $rows[3] == 0; etc. So far I am not getting anything like that from the script. Do you think this is happening because of the second loop? --- "Atkinson, Robert" <ratkinson@xxxxxxxxxxxxx> wrote: > Breakdown of script :- > > > // We need to know how many rows there are in the > '$rows' array, > // so we can loop through each one looking at all of > the values, > // which is held in $max_rows > > $max_rows = count($rows); > > // Firstly, we loop around every instance of $rows, > using 'foreach'. > // The key to the $rows array, i.e. 0, 1, 2, 3, etc > is loaded into > // $array_key and the value is loaded in > $array_value. > // > // Remember that $array_value is an array itself, > but PHP > // is quite happy with this as it is a 'loosely > typed' language, so > // you can load any type of value into any variable > // > // There are 2 loops going on in the code, one to > take us through each > // row as a main loop, and another to go back > through all the rows at the > // time, comparing the row to all of the other rows > // > // If we were to look inside the loops, we would see > something like this :- > // > // MAIN LOOP SUB-LOOP > // current row -> compare to > // 0 1 > // 0 2 > // 0 3 > // 1 0 > // 1 2 > // 1 3 > // 2 0 > // 2 1 > // 2 3 > // 3 0 > // 3 1 > // 3 2 > // > // Notice that we never compare the current row to > itself, we simply > // step over it > // > > foreach ($rows as $array_key => $array_value) { > > // lets output a message to say which array row > we're currently > working on > // We know which one it is, because we loaded that > information in > // $array_key, i.e. 0, 1, 2, etc > > echo "<br>Curr row = " . $array_key . " - <br>\n"; > > // Now the good bit > // We have to loop round all of the rows (in $rows) > independently of > the loop > // we're doing in our 'foreach' above, but we must > not compare the > row to > // inself > // > // First of all, we set a counter, called $i, to > zero > // We keep looping round until we get to the end of > the rows, by > looking at > // the value of $max_rows > > for ($i = 0; $i < $max_rows; $i++) { > > // In this statement we check to see if the row > we're > currently > // checking in our 'for' loop, is the same row as > the row > we're on > // in our 'foreach' loop. Remember, we must not > compare a row > to itself > > if ($array_key <> $i) { > > // Compare the elements in $array_value, which > holds > the current > // $rows array to the current $rows in our 'for' > loop, and store the results > // in $common > > $common = array_intersect($array_value, > $rows[$i]); > > // Loop round each of the matching values, in > $common, and output them > > foreach ($common as $key => $value) { > echo "Key: $key; Value: $value\n"; > } > echo "<BR>"; > } > } > } > > -----Original Message----- > From: php-objects@xxxxxxxxxxxxxxx > [mailto:php-objects@xxxxxxxxxxxxxxx] On > Behalf Of Robert Barker > Sent: 17 January 2008 18:11 > To: php-objects@xxxxxxxxxxxxxxx > Subject: RE: HOW DO I CREATE A LOOP > CRAWLER? > > EXCELLENT WORK ROB. THANK YOU VERY MUCH. > > *********************************************************************************** > Any opinions expressed in email are those of the > individual and not necessarily those of the company. > This email and any files transmitted with it are > confidential and solely for the use of the intended > recipient > or entity to whom they are addressed. It may contain > material protected by attorney-client privilege. If > you are not the intended recipient, or a person > responsible for delivering to the intended > recipient, be advised that you have received this > email in error and that any use is strictly > prohibited. > > Random House Group + 44 (0) 20 7840 8400 > http://www.randomhouse.co.uk > http://www.booksattransworld.co.uk > http://www.kidsatrandomhouse.co.uk > Generic email address - enquiries@xxxxxxxxxxxxxxxxx > > Name & Registered Office: > THE RANDOM HOUSE GROUP LIMITED > 20 VAUXHALL BRIDGE ROAD > LONDON > SW1V 2SA > Random House Group Ltd is registered in the United > Kingdom with company No. 00954009, VAT number > 102838980 > *********************************************************************************** > > ___________________________________________________________ Yahoo! Answers - Got a question? Someone out there knows the answer. Try it now. http://uk.answers.yahoo.com/