Hướng dẫn dùng fputcsv trong PHP
❮ Tham chiếu hệ thống tệp PHP Ví dụĐịnh dạng một dòng dưới dạng CSV và ghi nó vào một tệp đang mở:
$list = array $file = fopen(“contacts.csv”,”w”); foreach ($list as $line) { fclose($file); Định nghĩa và Cách sử dụngHàm fputcsv () định dạng một dòng dưới dạng CSV và ghi nó vào một tệp đang mở. Mẹo: Cũng xem hàm fgetcsv () . Cú pháp fputcsv(file, fields, separator, enclosure, Giá trị tham số
Chi tiết kỹ thuật
❮ Tham chiếu hệ thống tệp PHP botvietbai.com BCK là giải pháp tích hợp thanh toán MOMO, ViettelPay, VNPay, Vietcombank, Vietinbank, Techcombank, MB.. dành cho cá nhân ! (PHP 5 >= 5.1.0, PHP 7, PHP 8) fputcsv — Format line as CSV and write to file pointer Descriptionfputcsv( Parametersstream The file pointer must be valid, and must point to a file successfully opened by fopen() or fsockopen() (and not yet closed by fclose()). fields An array of strings. separator
The optional enclosure The optional escape The optional eol The optional
Return Values Returns the length of the written string or Changelog
ExamplesExample #1 fputcsv() example
= array ( The above example will write the following to aaa,bbb,ccc,dddd 123,456,789 """aaa""","""bbb""" Notes
See Also
MagicalTux at ooKoo dot org ¶ 15 years ago
bl at mindbench dot nl ¶ 15 years ago
mikhail dot galanin at yahoo dot com ¶ 4 years ago
Anonymous ¶ 6 years ago
julian at polygon dot red ¶ 2 years ago
reinhold dot egenter at gmail dot com ¶ 1 year ago
alex /-\-l- windeagle DOT org ¶ 13 years ago
jamie at agentdesign dot co dot uk ¶ 11 years ago
$attachment) { nate at example dot com ¶ 13 years ago
?>
Biniam Nigusse ¶ 6 years ago
soapergem at gmail dot com ¶ 13 years ago
perske at muenster dot de ¶ 4 years ago
ifunk ¶ 14 years ago
fputcsv(&$handle, $fields = array(), $delimiter = ',', $enclosure = '"') { simeonl at dbc dot co dot nz ¶ 12 years ago
fputcsv($fp, $row, $delimiter, $enclosure) === false) jon+dontspamme at phpsitesolutions dot com ¶ 14 years ago
$delimiter!=NULL) { drew at zitnay dot com ¶ 17 years ago
strlen($str);
mike at fatica dot net ¶ 8 years ago
David Thomas ¶ 10 years ago
R dot Mansveld at Spider-IT dot de ¶ 8 years ago
encode ¶ 9 months ago
johannes dot kingma at gmail dot com ¶ 11 months ago
mnz ¶ 3 years ago
$associative_array as $value) { alanzhang717 at gmail dot com ¶ 8 years ago
boonerunner at hotmail dot com ¶ 16 years ago
$string = "";// No leading delimiter iam at thatguy dot co dot za ¶ 8 years ago
gildas dot quemener at gmail dot com ¶ 9 years ago
bienvenunet at yahoo dot com ¶ 5 years ago
alexxed thething gmail thething com ¶ 15 years ago
|