I have created an array using
$processed[$y] = array('source' => $source,
'check total' => number_format($checkTotal, 2, '.', ''),//($rows['total'], 2, '.', ''),
'check number' => $num,
'table' => $invTable,
'skus' => $skuArray,
'check amount' => number_format($amount, 2, '.', '')
);
$y++;
My $skuArray is an array that contains all of the sku's that are associated with a specific check number. I am attempting to have it displayed like:
source check total check number table skus check amount
MNC 152.32 649 inv_temp 10198547 152.32
10195874
so it will list all of the sku's attached to a specific check nuimber before it lists the next item.
Here is my function to convert $processed to a csv file:
function to_csv( $array ) {
$csv = "";
if (count($array) == 0) return "No Processed checks found";
## Grab the first element to build the header
$arr = array_pop( $array );
$temp = array();
foreach( $arr as $key => $data ) {
$temp[] = $key;
}
$csv = implode( ',', $temp ) . "\r\n";
## Add the data from the first element
$csv .= to_csv_line( $arr );
## Add the data for the rest
foreach( $array as $arr ) {
$csv .= to_csv_line( $arr );
}
return $csv;
}
function to_csv_line( $array ) {
$temp = array();
foreach( $array as $elt ) {
$temp[] = '"' . addslashes( $elt ) . '"';
}
$string = implode( ',', $temp ) . "\r\n";
return $string;
}
How can I accomplish this? I have tried using array('skus=>$skuArray), but it just gave me "Array" in the results.
UPDATE: Here is what the array looks like when I do a var_dump($skuArray) array(1075) { [0]=> string(8) "10182997" [1]=> string(8) "10190313" [2]=> string(8) "10190314" [3]=> string(8) "10190315" etc.