Forum Moderators: coopster

Message Too Old, No Replies

How to match two dimensional arrays

How to match two dimensional arrays

         

npulis

10:20 pm on Jan 12, 2010 (gmt 0)



I have an 2 dimension array with $array[counter][id] and I have another w dimension array with $otherarray[counter][id].

Is is possible to match them as follows?
$array[counter][id] Match on $otherarray[counter][id]

I have tried the below... but it didn't work :(

do
{
if (in_array ($postchannels[$channelpopulatecounter][0], $postpullchannels) == true)
{echo "<input type=\"checkbox\" name=\"channels[]".$postchannels[$channelpopulatecounter][1]."\" value=\"".$postchannels[$channelpopulatecounter][0]."\" checked>".$postchannels[$channelpopulatecounter][1]."<br/>";}
$channelpopulatecounter += 1;
} while ($channelpopulatecounter != $channelpopulatetotal)

npulis

10:30 pm on Jan 12, 2010 (gmt 0)



For example:

I have an Array as:
$test[0][zero]....$test[10][ten]

And I have another Array as:
$nope[5][five]....$nope[7][seven]

And I need to check if any second dimension of $test can be matched with the second dimension of $nope.

Thanks :)

coopster

12:53 pm on Jan 22, 2010 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You need to match fully on same index. Something like

if ($postchannels[$channelpopulatecounter][0] == $postpullchannels[$channelpopulatecounter][0])

npulis

1:03 pm on Jan 22, 2010 (gmt 0)



Thanks