Jump to content

PHP If, While, Array for all Combination in the post


emmontenegro
 Share

Go to solution Solved by Barand,

Recommended Posts

    $space = array('3x3', '3x3_6x6', '3x3_6x6', '6x6_10x10', '10x10_20x20', '20x20_40x40', 'above_40x40');

    $location = array('schools', 'malls', 'publicParks_outdoorAreas','residentialCompounds');

    $ageGroup = array('6_12yo','13_18yo');

    $duration = array('20mins', '1hour', '4hours','4_6hours');

    $footfall = array('100', '100_500', 'above_500');

 

The above codes are the arrays for my system

 

What I need is a simplified algorithm for this output:

 

- 3x3, schools, 6-12 y/o, 20mins, 100 = SOMETHING HERE

- 3x3, schools, 6-12 y/o, 20mins, 100-500 = SOMETHING HERE

- 3x3, schools, 6-12 y/o, 20mins, Above 500 = SOMETHING HERE

- 3x3, schools, 6-12 y/o, 1 hour, 100 = SOMETHING HERE

- 3x3, schools, 6-12 y/o, 1 hour, 100-500 = SOMETHING HERE

- 3x3, schools, 6-12 y/o, 1 hour, Above 500 = SOMETHING HERE

- 3x3, schools, 6-12 y/o, 4 hour, 100 = SOMETHING HERE

- 3x3, schools, 6-12 y/o, 4 hour, 100-500 = SOMETHING HERE

- 3x3, schools, 6-12 y/o, 4 hour, Above 500 = SOMETHING HERE

- 3x3, schools, 6-12 y/o, 4-6 hour, 100 = SOMETHING HERE

- 3x3, schools, 6-12 y/o, 4-6 hour, 100-500 = SOMETHING HERE

- 3x3, schools, 6-12 y/o, 4-6 hour, Above 500 = SOMETHING HERE

- 3x3, schools, 13-18 y/o, 20mins, 100 = SOMETHING HERE

- 3x3, schools, 13-18 y/o, 20mins, 100-500 = SOMETHING HERE

- 3x3, schools, 13-18 y/o, 20mins, Above 500 = SOMETHING HERE

- 3x3, schools, 13-18 y/o, 1 hour, 100 = SOMETHING HERE

- 3x3, schools, 13-18 y/o, 1 hour, 100-500 = SOMETHING HERE

- 3x3, schools, 13-18 y/o, 1 hour, Above 500 = SOMETHING HERE

- 3x3, schools, 13-18 y/o, 4 hour, 100 = SOMETHING HERE

- 3x3, schools, 13-18 y/o, 4 hour, 100-500 = SOMETHING HERE

- 3x3, schools, 13-18 y/o, 4 hour, Above 500 = SOMETHING HERE

- 3x3, schools, 13-18 y/o, 4-6 hour, 100 = SOMETHING HERE

- 3x3, schools, 13-18 y/o, 4-6 hour, 100-500 = SOMETHING HERE

- 3x3, schools, 13-18 y/o, 4-6 hour, Above 500 = SOMETHING HERE

- 3x3_6x6...etc...

 

I tried this code, but I'm lost: 

 

    if (in_array($post_space, $space) && 

    in_array($post_location, $location) &&

    in_array($post_ageGroup, $ageGroup) &&

    in_array($post_duration, $duration) &&

    in_array($post_footfall, $footfall)) {

    

    }

 

I want every combination to consider.

 

Please help. Thanks!

Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.