PHP fgets read string and explode split string array by row

Source: Internet
Author: User
Tags explode

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

<?php$f= fopen ("file.txt", "R"), while (!feof ($f)) {  $line = fgets ($f);  echo $line, "<br/>"; $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 "</br>"; echo $dir _name;echo "</br>", Echo $file _name;echo "</br>"; Echo $file _size;echo "</br>"; Echo $create _ Time;echo "</br>";} Fclose ($f);? >

Results show


PHP fgets read string and explode split string array by row

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.