PHPfgets reading strings by row and splitting strings by explode as arrays _ PHP Tutorial

Source: Internet
Author: User
PHPfgets reads the string by row and splits the string by explode into an array. Phpfgetsextract strings by row and explodesplit strings are several File.txt types | directory | File | size | creation time File | C: ProgramFilesJavajre7libziAmericaIndiana | Veva PHP fgets reads strings by line and explode splits strings into arrays

File.txt

Type | directory | file | size | creation time

File|C:\Program Files\Java\jre7\lib\zi\America\Indiana|Vevay|724|2014-10-13 09:36 File|C:\Program Files\Java\jre7\lib\zi\America\Indiana|Vincennes|884|2014-10-13 09:36File|C:\Program Files\Java\jre7\lib\zi\America\Indiana|Winamac|932|2014-10-13 09:36 Directory|C:\Program Files\Java\jre7\lib\zi\America|Indiana|0|2014-10-13 09:36

Readfile. php

 ";$str = explode("|",$line);//print_r($str);$file_type =  $str [0];$dir_name =  $str [1];$file_name =  $str [2];$file_size =  $str [3];$create_time =  $str [4];echo $file_type;echo "
";echo $dir_name;echo "
";echo $file_name;echo "
";echo $file_size;echo "
";echo $create_time;echo "
";}fclose($f);?>

Result Display

File|C:\Program Files\Java\jre7\lib\zi\America\Indiana|Vevay|724|2014-10-13 09:36 FileC:\Program Files\Java\jre7\lib\zi\America\IndianaVevay7242014-10-13 09:36 File|C:\Program Files\Java\jre7\lib\zi\America\Indiana|Vincennes|884|2014-10-13 09:36 FileC:\Program Files\Java\jre7\lib\zi\America\IndianaVincennes8842014-10-13 09:36 File|C:\Program Files\Java\jre7\lib\zi\America\Indiana|Winamac|932|2014-10-13 09:36 FileC:\Program Files\Java\jre7\lib\zi\America\IndianaWinamac9322014-10-13 09:36 Directory|C:\Program Files\Java\jre7\lib\zi\America|Indiana|0|2014-10-13 09:36 DirectoryC:\Program Files\Java\jre7\lib\zi\AmericaIndiana02014-10-13 09:36 


The http://www.bkjia.com/PHPjc/953329.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/953329.htmlTechArticlePHP fgets reads strings by line and explode splits strings into arrays of file.txt type | directory | File | size | creation time File | C: \ Program Files \ Java \ jre7 \ lib \ zi \ America \ Indiana | Veva...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.