Skip to content

Instantly share code, notes, and snippets.

@mschultheiss83
Created July 7, 2014 19:01
Show Gist options
  • Save mschultheiss83/f18e82f688d0bcfcbe98 to your computer and use it in GitHub Desktop.
Save mschultheiss83/f18e82f688d0bcfcbe98 to your computer and use it in GitHub Desktop.
test file
<?php
/**
* @author mschultheiss83
* https://github.com/mschultheiss83
*/
/**
* @param array $arrData
* @param bool $bIncludeHeader
* @return string
*/
function array_2_csv($arrData = array(), $bIncludeHeader = false ) {
$csv = array();
if ($bIncludeHeader) {
$csv[] = array_2_csv(array_keys($arrData));
}
foreach ($arrData as $item) {
if (is_array($item)) {
$csv[] = array_2_csv($item);
} else {
$csv[] = $item;
}
}
return implode(';', $csv);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment