Advertisement
julong

php read data from text.txt #php

Sep 26th, 2014
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. ///
  2. a|b|c|d|e|f|g|h|i\n
  3. a2|b2|c2|d2|e2|f2|g2|h2|i2\n
  4. ////
  5. foreach(file('data.dat') AS $row) {
  6. $datas[] = explode('|', $row);
  7. }
  8. print_r($datas);
  9.  
  10. or
  11.  
  12. $file="person.txt";
  13. foreach(file($file) AS $row) {
  14. $arr = explode('|', $row);
  15. $arr_num = count($arr);
  16. for ($j=0; $j < $arr_num; $j++) {
  17. echo "$arr[$j] ";
  18. }
  19. echo "<br>";
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement