📄 15c01-1.php
字号:
<?php// Define three arrays of data that we wish to write to disk, // each in a similar format:$line1 = array(27, 'Sally had a dog', 0.567, 'a');$line2 = array(42, "See\nJane\nrun", 1.7, 'f');$line3 = array(3, 'Once upon a "mid-day" sunny ...', 3.14, 'p');// Now open a CSV file to write these out to:$csv = fopen('test.csv', 'w');// And put these lines in it as csv: Will output similar to:// 27,"Sally had a dog",0.567,afputcsv($csv, $line1);fputcsv($csv, $line2);fputcsv($csv, $line3);// Now close the file.fclose($csv);// Now let's open it back up to read from it:$readcsv = fopen('test.csv', 'r');// Read in each line, and dump it to the screen ... each line will be// an array holding one entry per CSV value:echo "<pre>";while ($line = fgetcsv($readcsv)) { print_r($line);}echo "</pre>";// Close the file:fclose($readcsv);?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -