View Single Post
  #1 (permalink)  
Old 02-13-10, 22:06
gilgalbiblewhee gilgalbiblewhee is offline
Registered User
 
Join Date: Jul 2004
Posts: 494
how to create a sub array

I'm trying to figure out how to make an array within an array. A sub array.
The first array has 54 fields (for a db table). Then 90 records. In other words I'm trying to loop the 54 fields 90 times. This was extracted by an html table using regexp. And the first array was 54X90 results.
PHP Code:
$record = array();
$fields = array();
$numrecords count($tdInnerHTML[1])/count($thInnerHTML[1]); //to find out the number of records
echo $numrecords;
for(
$rec=0$rec<$numrecords$rec++){ //90 records
    
$records[$rec] = array();
    if(
$rec==0){
        for (
$getTds 0$getTds count($thInnerHTML[1]); $getTds++){ //54 columns per record
            
$record[] = $tdInnerHTML[1][$getTds];
        }
    }else{
        
$column count($thInnerHTML[1])*($rec+1);
        
$min = (count($thInnerHTML[1])*$rec);
        for (
$getTds $min $getTds $column$getTds++){ //54 columns per record
            
$record[] = $tdInnerHTML[1][$getTds];
        }    
    }
    
$records[$rec][] = implode(", "$record);

Reply With Quote