Jump to content

Help Parsing flatfile?


stylus277

Recommended Posts

I have a flatfile named PROBINFO.cap. There isn't really a delimiter (not CSV...) each line is a record.

 

I would like to set a VAR for each line and autonumber till it is done. So far I can get it to read the file and echo it back on to the screen. But I cannot set the variables correctly.

 

<?php 
$fp = fopen('PROBINFO.cap','r'); 
if (!$fp) {echo 'ERROR: Unable to open file.'; exit;} 
  
while (!feof($fp)) { 
$line = fgets($fp, 1024);
list ($field1) = split ('\|', $line); 


echo ' 
'.$field1.'<br>'; 
$fp++; 
} 
  
fclose($fp); 
?> 

 

 

 

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/112947-help-parsing-flatfile/
Share on other sites

thanks for the reply, I did not get too far with it though.

 

To try and clearify my question, how would I open PROBINFO.cap and use each individual line as a value to set unique variables?

 

 

Set:

  $Var1 = ($line1)

  $Var2 = ($line2)

  $Var3 = ($line3)

  $Var4 = ($line4)

 

Thanks

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.