title: How to put switch case statement inside a foreach loop in php?
body: <p>I have the following conditional statement inside the foreach loop. I want all the conditional statements to be checked. I hope that it would be able to done by using switch case statements. Can anyone give me an idea how to do that? or is there any other way to do that? some dates have the values regarding to all four conditions. they won't be check if i use this code. Since i am new to this its hard me to figure out how to do that. It would be a great help if anyone can give an idea.</p>
  
  <pre><code>foreach ($query-&gt;result() as $row) {
  
              if ($row-&gt;title == 'GK' &amp;&amp; $row-&gt;type == 'AM') {
                  $cal_data[substr($row-&gt;date_cal, 8, 2)] = '&lt;div class="gk_am"&gt;' . $row-&gt;title . ' ' . $row-&gt;type . '&lt;/div&gt;';
              }  if ($row-&gt;title == 'GK' &amp;&amp; $row-&gt;type == 'PM') {
                  $cal_data2[substr($row-&gt;date_cal, 8, 2)] = '&lt;div class="gk_pm"&gt;' . $row-&gt;title . ' ' . $row-&gt;type . '&lt;/div&gt;';
              } if ($row-&gt;title == 'RP' &amp;&amp; $row-&gt;type == 'AM') {
                  $cal_data3[substr($row-&gt;date_cal, 8, 2)] = '&lt;div class="rp_am"&gt;' . $row-&gt;title . ' ' . $row-&gt;type . '&lt;/div&gt;';
              } if ($row-&gt;title == 'RP' &amp;&amp; $row-&gt;type == 'PM') {
                  $cal_data4[substr($row-&gt;date_cal, 8, 2)] = '&lt;div class="rp_pm"&gt;' . $row-&gt;title . ' ' . $row-&gt;type . '&lt;/div&gt;';
              }     
  
  
          } 
  </code></pre>