Searching nested array

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
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Searching nested array

Post by aceconcepts »

Hi,

I have been able to add to my array using the following method:

Code: Select all

 
$_SESSION['selectedStageQuestions'][$key][$stage][]=$value;
 
Now what I want to be able to do is search the third nested array (shown above).

How would I use in_array() or other function to search that third array?

Thanks.
User avatar
EverLearning
Forum Contributor
Posts: 282
Joined: Sat Feb 23, 2008 3:49 am
Location: Niš, Serbia

Re: Searching nested array

Post by EverLearning »

Code: Select all

in_array($searchingFor, $_SESSION['selectedStageQuestions'][$key][$stage])
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: Searching nested array

Post by aceconcepts »

Yeh, this is what I thought. I tried this before but it didnt work.

I'll have to go back and re-think.
Post Reply