Processing variable-length text fields : explode « Data Structure « PHP






Processing variable-length text fields

 
<?php
$delim = '|';

$fh = fopen('books.txt','r') or die("can't open: $php_errormsg");
while (! feof($fh)) {
    $s = rtrim(fgets($fh));
    $fields = explode($delim,$s);
}
fclose($fh) or die("can't close: $php_errormsg");
?>
  
  








Related examples in the same category

1.Breaking Strings into Arrays with explode()
2.Display year an individual was born
3.Using the explode() Function
4.Generating an ID with microtime()
5.explode( ) function converts a string into an array using a separator value
6.explode() function divides string into various elements, returning these elements in an array.
7.explode.php
8.Using explode() with date()
9.Reading and Writing Comma-Separated Data