php - in_array() for array of array

414

Is there a function likein_array() than can, check conntent inside array of arrays?

I tried:

$day_events = Array();
array_push($day_events,array('aa','bb','cc'));
array_push($day_events,array('aa','bc','cd'));
array_push($day_events,array('ac','bd','ce'));
echo '<br />';
echo in_array('aa',$day_events); // empty
echo '<br />';
foreach ($day_events as &$value) {
    echo in_array('aa',$value); // 11
}

first in_array() which is the kind of function I am looking for (avoiding the loop) gave empty.

887

Answer

Solution:

By the way it is not avoiding first one it is avoiding the last one which has 'ac'. So you get true from first two. Your code works but I am not sure if that is what you want.

People are also looking for solutions to the problem: php - Output three columns and row in loop

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.