得到这段代码php
header("Content-Type: application/octet-stream");
$file = $_GET["file"] .".pdf";
header("Content-Disposition: attachment; filename=" . urlencode($file));
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Description: File Transfer");
header("Content-Length: " . filesize($file));
flush(); // this doesn't really matter.
$fp = fopen($file, "r");
while (!feof($fp))
{
echo fread($fp, 65536);
flush(); // this is essential for large downloads
}
fclose($fp);
我想打印连续的第一列,用逗号和空格分隔元素,以获得此结果:
$data ='
one;uno
two;dos
three;tres
four;cuatro
'
请帮忙吗?我这样做但我不能:
one, two, three, four
答案 0 :(得分:1)
尝试修改后的代码版本
$data ='one;uno
two;dos
three;tres
four;cuatro';
$coma=array();
$line = explode("\n", $data);
for($i = 0; $i<count($line); $i++) {
$item = explode(";", $line[$i]);
$coma[]= $item[0];
}
echo implode(',',$coma);