Jump to content

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

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.