Joso Marich
Joso Marich

Reputation: 29

array_search does not work properly in foreach

For some reason when I put this array through foreach it does not work properly. What am I doing wrong?

array (size=2)'Final' => array (size=1)'sender' => array (size=1)'asd' => array (size=2)...'Hos' => array (size=1)'sender' => array (size=1)'asd' => array (size=2)...

foreach($sent_app_groups['title'] as $k => $v) {
    $pill_title = array_search($sent_app_groups['title'][$k],$sent_app_groups['title']); 
    echo $pill_title;
}

The result should be:

Final Hos

But I always get:

Final Final

Upvotes: 1

Views: 421

Answers (1)

Joso Marich
Joso Marich

Reputation: 29

I guess this is the right way to do it, silly me :P But still I don't get it, shouldn't it do the same thing with array_search?

foreach($sent_app_groups['title'] as $k => $v) { $pill_title = $k; echo $pill_title; }

Upvotes: 1

Related Questions