Three Array values to export-csv

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hjaffer2001
    New Member
    • Aug 2010
    • 4

    Three Array values to export-csv

    I have three array values using nested loop. Now i want to export the array values to csv(excel). The code is

    Code:
    for($j=0;$j<count($TimeEntriesList);$j++){
    			 	for($n=0;$n<count($TimeEntriesList[$j]['time-entry']);$n++){
    					$datee[] = $TimeEntriesList[$j]['time-entry'][$n]['date'];
    					$person_id[] = $TimeEntriesList[$j]['time-entry'][$n]['person-id'];
    					$project_id[] = $TimeEntriesList[$j]['time-entry'][$n]['project-id'];
    				    $desc[] = $TimeEntriesList[$j]['time-entry'][$n]['description'];
    			 		$hours[] = $TimeEntriesList[$j]['time-entry'][$n]['hours'];
    					unset($TimeEntriesList[$j]['time-entry'][$n]['todo-item-id']);
    					//$csv_hdr .= $datee[].",".$person_id[].",".$hours[].",".$desc[]."\n";
    					}
    			}
    How to export $date[],$project-id,$hours[],$desc to csv

    Thanks in advance
    Haan
  • dlite922
    Recognized Expert Top Contributor
    • Dec 2007
    • 1586

    #2
    CSV: Comma Separated Values.

    Thus a CSV file is a text file that has values separated by commas and line breaks.

    All you have to do is write your last line to a file. If you want the user to download it, change the header to attachment and csv file type with ".csv" extension.

    If the user has local software to open csv (such as Excel) then it will be opened in that software.


    Dan

    Comment

    Working...