php - Separate multidimentional array into separate arrays -


i trying head around arrays.

the arrays should this:

$questions[$a] => array( [0] => no, comment1                          [1] => yes, comment2                          [2] => no, comment3 )  $answer[$a] => array( [0] => no                       [1] => yes                       [3] => no )  $comment[$a] => array( [0] => comment1                        [1] => comment2                        [3] => comment3 ) 

=========================================================================

second edit: need execute in loop create third array -

if($answer[$a] == "yes") { $display[$a] = "style='display:none'";  } else { $display[$a] = "style='display:block'"; } 

this have: (28th minitech)

while ($a > $count) { if($count > 11) { foreach($questions $q) {     list($answer, $comments[]) = explode(',', $q);     if($answer === "yes") {      $display[$a] = "style='display:none'";      } else {      $display[$a] = "style='display:block'";      }  $answers[] = $answer;     }   } $a++; } 

if strings, explode works:

$answers = array(); $comments = array(); $display = array();  foreach(array_slice($questions, 11) $question) {     list($answer, $comments[]) = explode(',', $question);     $display[] = $answer === 'yes' ? 'style="display: none"' : 'style="display: block"';     $answers[] = $answer; } 

here’s demo!


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -