第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何使用 PHP 打印 CSV 文件的行?

如何使用 PHP 打印 CSV 文件的行?

PHP
守著一只汪 2023-07-08 20:27:59
這是我正在使用的代碼,但它并沒有準確輸出我想要的內(nèi)容。<?php$file = fopen("ad.csv","r");while(! feof($file))  {  print_r(fgetcsv($file));  }fclose($file);?>這是它當(dāng)前輸出的內(nèi)容:Array ( [0] => cn [1] => mail [2] => telephonenumber [3] => uid ) Array ( [0] => [1] => [2] => [3] => ) Array ( [0] => admin [1] => [2] => [3] => ) Array ( [0] => Isaac Newton [1] => newton@ldap.forumsys.com [2] => [3] => newton ) Array ( [0] => Albert Einstein [1] => einstein@ldap.forumsys.com [2] => 314-159-2653 [3] => einstein ) Array ( [0] => Nikola Tesla [1] => tesla@ldap.forumsys.com [2] => [3] => tesla ) Array ( [0] => Galileo Galilei [1] => galieleo@ldap.forumsys.com [2] => [3] => galieleo ) Array ( [0] => Leonhard Euler [1] => euler@ldap.forumsys.com [2] => [3] => euler ) Array ( [0] => Carl Friedrich Gauss [1] => gauss@ldap.forumsys.com [2] => [3] => gauss ) Array ( [0] => Bernhard Riemann [1] => riemann@ldap.forumsys.com [2] => [3] => riemann ) Array ( [0] => Euclid [1] => euclid@ldap.forumsys.com [2] => [3] => euclid ) Array ( [0] => Mathematicians [1] => [2] => [3] => ) Array ( [0] => Scientists [1] => [2] => [3] => ) Array ( [0] => read-only-admin [1] => [2] => [3] => ) Array ( [0] => Italians [1] => [2] => [3] => ) Array ( [0] => Test [1] => [2] => [3] => test ) Array ( [0] => Chemists [1] => [2] => [3] => ) Array ( [0] => Marie Curie [1] => curie@ldap.forumsys.com [2] => [3] => curie ) Array ( [0] => Alfred Nobel [1] => nobel@ldap.forumsys.com [2] => [3] => nobel ) Array ( [0] => Robert Boyle [1] => boyle@ldap.forumsys.com [2] => 999-867-5309 [3] => boyle ) Array ( [0] => Louis Pasteur [1] => pasteur@ldap.forumsys.com [2] => 602-214-4978 [3] => pasteur ) Array ( [0] => No Group [1] => nogroup@ldap.forumsys.com [2] => [3] => nogroup ) Array ( [0] => FS Training [1] => training@forumsys.com [2] => 888-111-2222 [3] => training ) Array ( [0] => FS Training [1] => jmacy-training@forumsys.com [2] => 888-111-2222 [3] => jmacy )換句話說,這幾乎就像將我所有的 CSV 數(shù)據(jù)添加到一個多維數(shù)組中一樣......
查看完整描述

1 回答

?
函數(shù)式編程

TA貢獻1807條經(jīng)驗 獲得超9個贊

順便說一句,在 php 7.2 中這也可以工作:


? ? <?php

? ? $row = 1;

? ? if (($handle = fopen("ad.csv", "r")) !== FALSE) {

? ? ? ? while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {

? ? ? ? ? ? echo ($data[0].",".$data[1].",".$data[2].",".$data[3]."\n");

? ? ? ? }

? ? ? ? fclose($handle);

? ? }

? ? ?>

此外,.csv 數(shù)據(jù)上的引號應(yīng)包含所有數(shù)據(jù),例如:


"Isaac Newton","newton@ldap.forumsys.com",,"newton"

"Albert Einstein","einstein@ldap.forumsys.com","314-159-2653","einstein"

"Nikola Tesla","tesla@ldap.forumsys.com",,"tesla"

"Galileo Galilei","galieleo@ldap.forumsys.com",,"galieleo"


查看完整回答
反對 回復(fù) 2023-07-08
  • 1 回答
  • 0 關(guān)注
  • 166 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號