PHP array manipulation

Posted by user295189 on Stack Overflow See other posts from Stack Overflow or by user295189
Published on 2010-05-06T04:41:07Z Indexed on 2010/05/06 4:48 UTC
Read the original article Hit count: 383

Filed under:
|
|
|

I have the code below . it looks for the case and creates an array of rows and columns. $pv->results[$row1][1][0] actually is $pv->result->[rownumber][coulmnnumber][0]. Now this is for only 2 columns as you can see. However I want an array like $myArr = array(0=>1, 1=>7, 2=>8, 3=>9 ) to be added below for column. What it is doing, is adding 4 columns (0,1,2,3) into the code below. So now I will have 4 cases instead of 2 cases as I need to more columns. Also the case value will not be 1 and 2, it will be 1, 7, 8 and 9 respectively. How can I do that? Thanks.

for($i=0;$i<count($pv->rawData); $i++){ 
SWITCH ($pv->rawData[$i]->my ID){
         CASE '1':
          $row1++;
          $pv->results[$row1][1][0] =  $pv->rawData[$i]->data;

           break;

        CASE '2':
          $row2++;
         $pv->results[$row2][2][0] =  $pv->rawData[$i]->data;

          break;    
}       

© Stack Overflow or respective owner

Related posts about php

Related posts about php5