#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    59
    Rep Power
    15
    I want to read a text file into an array and then check each element to see if it is over 80 chars, and if it is to go to the nearest space before or the 80th char, and move it into the next element. Basically I want to do justified paragraphs server-side, so that I then can add line numbers to the edge, so that it can be used as a legal type document. Has anyone done anything like this before?

    Thanks
    Chris
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2000
    Posts
    5
    Rep Power
    0
    Hi chirs!

    You can use the following code may be it will solve your problem.

    for text file open

    $fp = foprn("textfile.txt","r");
    $line_no = 1;
    while($line = fgets($fp,80))
    {
    echo $line_no.':'.$line.'<br>';
    }
    fclose($fp);

    if you any problem pls let me know the details

    Thanks and Regards
    Mariya.k
    Chennai - india
    mariyasikumar@yahoo.com



    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by Chris Pickett:
    I want to read a text file into an array and then check each element to see if it is over 80 chars, and if it is to go to the nearest space before or the 80th char, and move it into the next element. Basically I want to do justified paragraphs server-side, so that I then can add line numbers to the edge, so that it can be used as a legal type document. Has anyone done anything like this before?

    Thanks
    Chris
    [/quote]

  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    59
    Rep Power
    15
    Hey thx, that works except that it will cut a sentence off in mid-word, so it ends up with a word bneing half on one line and half on another, but I think by looking at your script I might have something worked out, Thanks again.

    Chris

Similar Threads

  1. defining array of characters
    By schorsche in forum C Programming
    Replies: 10
    Last Post: February 9th, 2004, 05:49 PM
  2. sort: find duplicate string elements in array
    By sciencelife in forum Java Help
    Replies: 3
    Last Post: January 27th, 2004, 02:29 PM
  3. C++ programming help.
    By Programming1 in forum C Programming
    Replies: 1
    Last Post: January 20th, 2004, 11:47 AM
  4. another remove array values from an array
    By robee in forum PHP Development
    Replies: 6
    Last Post: November 20th, 2003, 01:09 AM
  5. multi dimensional arrays - Can't grasp how to?
    By Kaleina in forum PHP Development
    Replies: 17
    Last Post: November 5th, 2003, 04:18 PM

IMN logo majestic logo threadwatch logo seochat tools logo