0

I have multidimensional array like this:

Array
(
    [0] => Array
        (
            [id] => 10184
            [meta_tags] => tag1,tag2

        )
)

How do i search by keyword (example, tag1) in an array.

Thank u.

1
  • 1
    ... and then take a look at this answer. Commented Mar 7, 2011 at 12:49

2 Answers 2

1
function ($haystack, $tag) {
    foreach ($haystack as $key => $value) {
        if (in_array($tag, explode(',', $value['meta_tags']) {
            return true;
        }
    }
}
Sign up to request clarification or add additional context in comments.

Comments

0

I think you have to use a recursive function since arrays don't have the same dimensions.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.