0

I have an array that I have a need to have a four step filter process to produce a result or set of results based on 3 conditions

For example this array that I pull from the db

Which returns:

Array (

[0] => Array ( [playlist_id] => 199 [playlist_name] => Christmas [playlist_status] => 1 [playlist_region] => Latin America [playlist_brand] => Sprite [playlist_year] => 2015 [playlist_type] => charter ) [1] => Array ( [playlist_id] => 200 [playlist_name] => World Cup [playlist_status] => 1 [playlist_region] => Latin America [playlist_brand] => Diet Coke [playlist_year] => 2014 [playlist_type] => charter )

)

Using php or javascript I am trying to do a deductive filter on the array. This array will grow a lot and a lot of these values will get duplicated. In this instance we have 2 Latin America for example.

The end goal is to have a radio select for Region (in this case there would only be one Latin America to represent all the values with Latin America). Anything NOT Latin America will not be shown in the 2nd step.

The 2nd step is a checkbox select for year(s). Anything not selected will not be available in the 3rd step. The 3rd step is a radio select for brand, anything not selected will not be shown in the final step.

Any ideas would be greatly appreciated.

1 Answer 1

0

I would do something like this:

<?php
    foreach($theArray as $key -> $value) {
        if(array_search($region, $value) {
            // include $theArray[$key] in step 2
        }
    }
?>
Sign up to request clarification or add additional context in comments.

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.