note 112968 added to function.ksort
| From: | Anonymous | Date: | Tue, 13 Aug 2013 13:11:32 +0000 |
| Subject: | note 112968 added to function.ksort | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-195949@lists.php.net to get a copy of this message | ||
Note that this function will output the given $fields in the order they were added to the data array
and not automatically in numerical key order.
To output in ascending key order, you'll need to ksort the array first (or use appropriate
natural order sorting, depending on your keys).
For example:
<?php
$data[2] = 'C';
$data[0] = 'A';
$data[1] = 'B';
fputcsv($fh, $data); // outputs: "C,A,B"
ksort($data);
fputcsv($fh, $data); // outputs: "A,B,C"
?>
----
Server IP: 69.147.83.199
Probable Submitter: 62.30.95.105
----
Manual Page -- http://php.net/manual/en/function.ksort.php
Edit -- https://master.php.net/note/edit/112968
Del: integrated -- https://master.php.net/note/delete/112968/integrated
Del: useless -- https://master.php.net/note/delete/112968/useless
Del: bad code -- https://master.php.net/note/delete/112968/bad+code
Del: spam -- https://master.php.net/note/delete/112968/spam
Del: non-english -- https://master.php.net/note/delete/112968/non-english
Del: in docs -- https://master.php.net/note/delete/112968/in+docs
Del: other reasons-- https://master.php.net/note/delete/112968
Reject -- https://master.php.net/note/reject/112968
Search -- https://master.php.net/manage/user-notes.php