Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 29th, 2012  |  syntax: None  |  size: 0.37 KB  |  hits: 23  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to read couple of numerical data from a file and assing them to some parameters?
  2. $file_contents = file_get_contents("text.txt");
  3. foreach(preg_split("/((r?n)|(rn?))/", $file_contents) as $line){
  4.     $arr = explode(" ", $line);
  5.  
  6.     if(is_numeric($arr[0])) {
  7.  
  8.         // set needed variables
  9.         $a = $arr[0];
  10.         $b = $arr[1];
  11.         $c = $arr[2];
  12.  
  13.     }
  14.  
  15. }