How to see if any values in array equal any values in anthr?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
3dron
Forum Commoner
Posts: 40
Joined: Sat Feb 01, 2003 10:25 pm

How to see if any values in array equal any values in anthr?

Post by 3dron »

How do I check all the values in one array against all the values in another array?


If any values in
$row_Comments['id'] == any values in $row_Posts['id']



I could figure it out with a while statement, but a little confusing for me. And I'm sure there is a simple way.

RR
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

3dron
Forum Commoner
Posts: 40
Joined: Sat Feb 01, 2003 10:25 pm

Post by 3dron »

I gues I'm stupid.

$row_Comments['id']
$row_Posts['id']

are reported as string with var_dump

How can I compare all their values?
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

another function

Post by phpScott »

while looping through one array you can compare that value to the other using
http://www.php.net/manual/en/function.in-array.php

phpScott
Post Reply