OSDN Git Service
(root)
/
wvm
/
wvm.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
ad58fc9
)
Use fputcsv with STDOUT instead of building our own CSV. Props @scribu
author
Daniel Bachhuber
<d@danielbachhuber.com>
Sun, 3 Feb 2013 20:23:14 +0000
(12:23 -0800)
committer
Daniel Bachhuber
<d@danielbachhuber.com>
Sun, 3 Feb 2013 20:23:14 +0000
(12:23 -0800)
php/utils.php
patch
|
blob
|
history
diff --git
a/php/utils.php
b/php/utils.php
index
f800312
..
fa878df
100644
(file)
--- a/
php/utils.php
+++ b/
php/utils.php
@@
-242,9
+242,8
@@
function recursive_unserialize_replace( $from = '', $to = '', $data = '', $seria
function output_csv( $headers = array(), $data = array() ) {
// Prepare the headers if they were specified
- if ( ! empty( $headers ) ) {
- echo '"' . implode( '","', $headers ) . '"' . PHP_EOL;
- }
+ if ( ! empty( $headers ) )
+ fputcsv( STDOUT, $headers );
foreach( $data as $row ) {
$row = (array)$row;
@@
-256,6
+255,6
@@
function output_csv( $headers = array(), $data = array() ) {
}
$row = $build_row;
}
-
echo '"' . implode( '","', $row ) . '"' . PHP_EOL
;
+
fputcsv( STDOUT, $row )
;
}
}