Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 4 of 4
  1. #1
    y2k
    y2k is offline
    Junior Member
    Join Date
    Feb 2003
    Location
    Ireland
    Posts
    29
    Member #
    694
    I'm quiet new to PHP, but to read the contents of a text file I use the following:
    Code:
    $filename "titles/image".$imageID.".txt";
    $fileToOpen = fopen($filename,"r");
    $content = fread($fileToOpen, filesize($filename));
    fclose($fileToOpen);
    This is working fine for me, but hoe do I change it so that $content can be an array instead of a variable. I want to create a new item in the array each time a newline is encountered. I've done some searching but to no avail.

    I'd appreciate any help anybody can give

  2.  

  3. #2
    Senior Member
    Join Date
    Aug 2003
    Posts
    444
    Member #
    2801
    Two ways:

    1. Quick and recommended way: use the file() function. It reads a text file into an array where each element of the array is a line in the file.

    2. Do as you are doing and then explode() the contents based on the \n delimiter. The explode() function returns an array.

    Search the PHP help for these two functions.
    eKstreme
    eKstreme.com - Free website tools!
    fontfox - free fonts Hand-picked quality fonts.

  4. #3
    y2k
    y2k is offline
    Junior Member
    Join Date
    Feb 2003
    Location
    Ireland
    Posts
    29
    Member #
    694
    Great, thank you so much for that I'll give it a go

  5. #4
    Senior Member Richard S's Avatar
    Join Date
    Jul 2004
    Location
    SW Lonodn
    Posts
    219
    Member #
    6728
    Liked
    3 times
    I've just been looking in to a good way to send HTML emails and came across this:

    http://us2.php.net/file

    Theres a code example part way down that may be useful.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 11:54 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com