PHP fgetcsv() ກົນວົງ
ການກໍານົດຄວາມຈະລືກການນັ້ນ
fgetcsv() ກົນວົງກວນຕະຫລອດຂອງຄິດຈາກຄຳບັນທຶກແລະຊອກຫາວົງCSV.
ກັບ fgets() ຄືກັນ, ແຕ່ຕະຫລອດ fgetcsv() ພະຍາຍາມບັນທຶກວົງຊື່ທີ່ເຂົ້າມາແລະຊອກຫາວົງຊື່CSV, ແລະກັບຄືນຄືວົງຊື່ຂອງວົງຊື່ດັ່ງກ່າວ.
fgetcsv() ບໍ່ມີຄວາມຜິດພາດກັບ FALSE, ລວມທັງຕອນທີ່ສະຫລອງເອກະສານ.
Note:ຕັ້ງແຕ່ PHP 4.3.5, fgetcsv() ການດຳເນີນງານຢູ່ຄວາມປອດໄພທາງບິນ.
ຄຳຖານ
fgetcsv(file,length,separator,enclosure
ຄຳປັບ | ການອະທິບາຍ |
---|---|
file | ຕ້ອງການ. ກໍານົດເອກະສານທີ່ຈະກວດສອບ. |
length |
ອະນຸຍາດ. ກໍານົດຄວາມຍາວສູງສຸດຂອງວົງຊື່. ຈະຕ້ອງຫລາຍກວ່າວົງຊື່ຍາວທີ່ຫລາຍທີ່ສຸດໃນເອກະສານ CSV. ຢູ່ PHP 5ການຄົ້ນຄວ້າຄຳປັບນັ້ນແມ່ນອະນຸຍາດຈະດຳເນີນງານບໍ່. ຢູ່ PHP 5ກ່ອນມັນຈະມີຄວາມຈໍາກັດ. ຖ້າບໍ່ອະນຸຍາດປະເພດຄຳປັບ(ຕັ້ງຄວາມຄິດໃນເຖິງ PHP 5.0.4 ຕໍ່ມາເປັນ 0)ຫຍັງຢູ່ນີ້ຫລັງຈາກນັ້ນຈະບໍ່ມີຄວາມຈໍາກັດຂອງຄວາມຍາວຈະຕົກລົງຕາມຈະຕົກລົງສຳລັບຄວາມປະສິດທິພາບຂອງການດຳເນີນງານ。 |
separator | Optional. Set the field separator (only one character is allowed), the default value is comma. |
enclosure |
Optional. Set the field delimiter (only one character is allowed), the default value is double quotes. This parameter was added in PHP 4.3.0. |
Tips and Notes
Note:Empty lines in the CSV file will be returned as an array containing a single null field and will not be treated as an error.
Note:This function is sensitive to locale settings. For example, if LANG is set to en_US.UTF-8, reading errors may occur in single-byte encoded files.
Note:If PHP cannot recognize the line ending of Macintosh files when reading files, you can activate the auto_detect_line_endings runtime configuration option.