Foreach string in php? -


im sure answer on web not sure of proper way search this.

foreach ($sections $key => $inside) {        foreach ($inside['fields'] $key => $field) {            echo '<li>'.var_dump ($field['type']).'</li>';        }  } 

this dumps list of strings.

string(6) "switch" string(6) "switch" string(4) "text" string(4) "text" string(8) "textarea" string(6) "switch" string(9) "radio_img" string(9) "radio_img" string(10) "multi_text"  

i want add 1 more foreach , is, foreach "switch" or whatever string desired in above list of strings.

so like

foreach ($sections $key => $inside) {        foreach ($inside['fields'] $key => $field) {              foreach ($field['type']['switch'] $string) {                  //loop through switches               }        }  } 

this new me , couldnt find answer google, not sure how specify string value , iterate each one.

the operation:

foreach ($sections $key => $inside) {     foreach ($inside['fields'] $key => $field) {         if($field['type'] == 'switch') {             echo '<div class="'.$field['id'].'-stackoverflow">mycontent</div>';         }      } } 

this output like

<div id="main-stackoverflow">mycontent</div> <div id="layout-stackoverflow">mycontent</div> <div id="colors-stackoverflow">mycontent</div> <div id="fonts-stackoverflow">mycontent</div> 

then use jquery display appropriate div in appropriate page, it's options panel , there options hidden, when main option selected main-stackoverflow div visable. rough desc.. guys helping, wish didnt have ask such easy question idea in head whole time, it's nice others input.

no need of third foreach.try like

foreach ($sections $key => $inside) {      foreach ($inside['fields'] $key => $field) {         if($field['type'] == 'switch') {             echo $filed['type'];             // or increment counter display how many times occurs             // $new_arr[] = $field['type']['switch'];         }      }  } 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -