Jump to content

Recommended Posts

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.

 

Link to comment
https://forums.phpfreaks.com/topic/86469-help-with-loop-crawler/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.