Each line is converted into an array : list « Utility Function « PHP






Each line is converted into an array

 
<?
    $filename='data.txt';
    $filearray = file($filename);

    if ($filearray) {
            while (list($var, $val) = each($filearray)) {
                    ++$var;
                    $val = trim($val);
                    print "Line $var: $val<br />";
            }
    } else {
            print "Could not open $filename.\n";
    }
?>
  
  








Related examples in the same category

1.list($maths, $english, , $biology) = $scores;
2.Using the list() function.
3.Extracting Values from an Array Using list()