JSON数据、PHP数组 转换 Excel表格
//excel输出 header("Content-type:application/vnd.ms-excel"); header("Content-Disposition:filename=".date("Ymd",time()).".xls"); echo "RealName\t"; echo "Mobile\t"; echo "GradeName\t"; echo "TeachMethod\t"; echo "CreatedOn\t\r\n"; $file_path = "data.txt"; $str = file_get_contents($file_path); $data = json_decode($str, true); //var_dump($data); foreach($data['rows'] as $k=>$rs){ echo $rs["RealName"]."\t"; echo $rs["Mobile"]."\t"; echo $rs["GradeName"]."\t"; echo $rs["TeachMethod"]."\t"; echo $rs["CreatedOn"]."\t\r\n"; } //$filename = '3.txt'; //$handle = fopen($filename, 'rb+'); // //while(!feof($handle)){ // // echo fgets($handle).'<hr/>'; // $str = fgets($handle); // // $data = json_decode($str, true); // // //var_dump($data); // // foreach($data['rows'] as $k=>$rs){ // echo $rs["RealName"]."\t"; // echo $rs["Mobile"]."\t"; // echo $rs["GradeName"]."\t"; // echo $rs["TeachMethod"]."\t"; // echo $rs["CreatedOn"]."\t\r\n"; // } //}