tinfanide Posted November 6, 2011 Share Posted November 6, 2011 Is there a command line in PHP which can export phpmyadmin data to csv files? Link to comment Share on other sites More sharing options...
justsomeguy Posted November 7, 2011 Share Posted November 7, 2011 phpmyadmin is written in PHP, so you can always get the source and look at the export commands. It's not a single line of code, it gets the data first and then outputs it. You can use this function to output an array as a line of CSV text: function array2csv ($fields, $delimiter = ',', $enclosure = '"', $mysql_null = false){ $delimiter_esc = preg_quote($delimiter, '/'); $enclosure_esc = preg_quote($enclosure, '/'); $output = array(); foreach ($fields as $field) { if ($field === null && $mysql_null) { $output[] = 'NULL'; continue; } $output[] = preg_match('/(?:'.$delimiter_esc.'|'.$enclosure_esc.'|\s)/', $field) ? ( $enclosure . str_replace($enclosure, $enclosure . $enclosure, $field) . $enclosure ) : $field; } return join($delimiter, $output);} Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.