RE: HOW DO I CREATE A LOOP CRAWLER?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Rob,

I used your formula and got nothing. Below is what I
did. Can you please tell me where I am going wrong?

<?php

$rows = array();
$rows[0] = array(4,11,24, 26,36,38, 45,35,44, 48); 
$rows[1] = array(1,0,13, 9,35,33,47, 25,39,55) ; 
$row3[2] = array(4,11,24,26,36,38,45,35,44,48); 
$row3[3] = array(1,0,13,9,35,33,47,25,39,55);  
$row3[4] = array(5,12,14,54,35,36,48,65,55,87);  
$row3[5] = array(0,2,55,26,41,36,67,35,36,69);   
$row3[6] = array(1,3,13,24,35,42,42,45,39,70); 
$row3[7] = array(1,2,3,64,8,37,6,49,35,36,48); 
$row3[8] = array(9,11,24,26,16,38,45,35,44,48); 
$row3[9] = array(3,0,13,9,35,23,47,25,39,55);  


$max_rows = count($rows) ;

foreach ($rows as $curr_row) {
for ($i = 0; $i <= $max_rows; $i++) {
$common = array_intersect( $curr_row, $rows[$i]);

foreach ($common as $key => $value) {
echo "Key: $key; Value: $value\n";
} 

echo "<BR>"
}
}

?>


Robert barker


--- "Atkinson, Robert" <ratkinson@xxxxxxxxxxxxx>
wrote:

> Very roughly.....
> 
> 
> $rows = array();
> $rows[0] = array(4,11,24,26,36,38,45,35,44,48); 
> $rows[1] = array(1,0,13,9,35,33,47,25,39,55);  
> ...etc,etc
> 
> This gives you a known list to work with. Now you
> can loop through the rows.
> 
> $max_rows = count($rows);
> 
> foreach ($rows as $curr_row) {
> 	for ($i = 0; $i <= $max_rows; $i++) {
> 		$common = array_intersect($curr_row, $rows[$i]);
> 
> 		foreach ($common as $key => $value) {
> 			echo "Key: $key; Value: $value\n";
> 		} 
> 
> 		echo "<BR>"
> 	}
> }
> 
> You will need to check and make sure $curr_row is
> not the same row as
> '$rows[$i]', otherwise you will always get a match
> (unless you want this of
> course).
> 
> Rob.
> 
> -----Original Message-----
> From: php-objects@xxxxxxxxxxxxxxx
> [mailto:php-objects@xxxxxxxxxxxxxxx] On
> Behalf Of Robert Barker
> Sent: 17 January 2008 14:57
> To: php-objects@xxxxxxxxxxxxxxx
> Subject:  HOW DO I CREATE A LOOP
> CRAWLER?
> 
> 
> Hello, I am very new to PHP and I am focusing on
> arrays to speed up my learning curse on the
> programme.
> The following is an array I am working with and I am
> stuck. Can anyone help please?
> 
> 
> <?php
> 
> // The following is a table
> 
> $row_1 = array(4,11,24,26,36,38,45,35,44,48); 
> $row_2 = array(1,0,13,9,35,33,47,25,39,55);  
> $row_3 = array(5,12,14,54,35,36,48,65,55,87);  
> $row_4 = array(0,2,55,26,41,36,67,35,36,69);   
> $row_5 = array(1,3,13,24,35,42,42,45,39,70); 
> $row_6 = array(1,2,3,64,8,37,6,49,35,36,48); 
> $row_7 = array(9,11,24,26,16,38,45,35,44,48); 
> $row_8 = array(3,0,13,9,35,23,47,25,39,55);  
> $row_9 = array(5,12,15,14,35,36,43,65,55,87);  
> $row_10 = array(0,5,55,26,31,36,67,35,36,69);   
> $row_11 = array(1,3,17,24,34,42,42,45,33,70); 
> $row_12 = array(1,1,3,66,8,37,6,49,35,36,48);
> $row_13 = array(0,2,55,26,41,36,67,35,36,69);   
> $row_14 = array(1,3,13,24,35,42,42,45,39,70); 
> $row_15 = array(1,2,3,64,8,37,6,49,35,36,48); 
> $row_16 = array(9,11,24,26,16,38,45,35,44,48); 
> $row_17 = array(3,0,13,9,35,23,47,25,39,55);  
> $row_18 = array(5,12,15,14,35,36,43,65,55,87);
> $row_19 = array(0,2,55,26,41,36,67,35,36,69);   
> $row_10 = array(1,3,13,24,35,42,42,45,39,70); 
> $row_21 = array(1,2,3,64,8,37,6,49,35,36,48); 
> $row_22 = array(9,11,24,26,16,38,45,35,44,48);  
> $row_23 = array(1,0,13,9,35,33,47,25,39,55);  
> $row_24 = array(5,12,14,54,35,36,48,65,55,87);  
> $row_25 = array(0,2,55,26,41,36,67,35,36,69);   
> $row_26 = array(1,3,13,24,35,42,42,45,39,70);
> $row_27 = array(1,2,3,64,8,37,6,49,35,36,48); 
> $row_28 = array(9,11,24,26,16,38,45,35,44,48); 
> $row_29 = array(3,0,13,9,35,23,47,25,39,55);  
> $row_30 = array(5,12,15,14,35,36,43,65,55,87);
> $row_31 = array(0,2,55,26,41,36,67,35,36,69)
>  
> 
> // Next is to find the common element(number) in
> each
> row
> 
> $common = array_intersect($row_1, $row_2);
> 
>     foreach ($common as $key => $value) {
>         echo "Key: $key; Value: $value\n";
>        } 
>        echo "<BR>"
> ?>
> 
> 
> 
> My problem is the above works only on $row_1 and
> $row_2, and I am stuck.
> 
> My question is two-fold. The first is, how do I
> write
> the LOOP to get $row_1 to go through and intersect
> with the rest of the rows in the table, that is, to
> intersect with $row_3, $row_4 etc and not just stop
> at
> $row_2?
> 
> The second question is; if the LOOP goes through to
> the end, how do I get it to start at row $row_2 as
> the
> main interceptor to repeat the process, after that
> $row_3 and so on and so forth.
>  
> 
> 
>      
>
__________________________________________________________
> Sent from Yahoo! Mail - a smarter inbox
> http://uk.mail.yahoo.com
> 
> 
> 
> Are you looking for a PHP job? Join the PHP
> Professionals directory Now!
> http://www.phpclasses.org/professionals/ 
> Yahoo! Groups Links
> 
> 
> 
> 
>
***********************************************************************************
> 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
>
***********************************************************************************
> 
> 



      ___________________________________________________________
Support the World Aids Awareness campaign this month with Yahoo! For Good http://uk.promotions.yahoo.com/forgood/

[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux