Jump to content

Recommended Posts

hey there.  I'm using file() to create an array of the lines from a .txt file.  I guess i have two questions.

1) how to I refer to each line individually after the array is created. 

          ie.  do action A to line 5.

2)  how would I search through that line in order to fine a specific character. 

              ex.  1 Product Name: Macromedia Director MX 2004 Bible

        so I want to loop through to ':' so I can cut of that part of the line and then display the rest of the line.

 

thanks for any help.

so that was very helpful but now i'm still running into a problem.  I print the specific line of the array just fine but when i use the explode function, it just prints the word "Array".

 


$filearray = file("ProductInfo.txt");
echo $filearray[2],"<BR>";


$portion = explode(":", $filearray[2]);
echo $portion,"<BR><BR>";

 

that's the code i have so far

It's because your missing the bracket parts when you use $portion. I don' know how your not getting a syntax error using commas for concating.

 

<?php

$filearray = file("ProductInfo.txt");
echo $filearray[2]."<BR>";

$portion = explode(":", $filearray[2]);
echo $portion[1]."<BR><BR>";

?>

wow that makes me sooo happy that works.  thanks a lot for your help.  ya i'm kinda new to php.  for some reason the comma's have been working pretty well. buut they're al changed to periods now that i know better.  thanks again!

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.