SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Feb 2006
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Parsing with php

    Hi. I need a php code that reads(parses) from a text file and write it to html. I need this to create a news site. If you have one, and share with me, i would be glad... Thanks

  2. #2
    SitePoint Evangelist ClickHeRe's Avatar
    Join Date
    Mar 2005
    Location
    Ottawa, Canada
    Posts
    580
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it would be helpful to know what kind of parsing and what is the format of the input file. And what you want as an end result.
    David

  3. #3
    SitePoint Evangelist
    Join Date
    Apr 2004
    Location
    Boston
    Posts
    482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Sleep Mode
    Hi. I need a php code that reads(parses) from a text file and write it to html. I need this to create a news site. If you have one, and share with me, i would be glad... Thanks
    did you try:

    PHP Code:
    $news file_get_contents(yourfile.txt);
    echo 
    $news

  4. #4
    Wadge! F4nat1c's Avatar
    Join Date
    Oct 2005
    Location
    South Wales, UK
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?php
    $file 
    "/somedir/somefile.txt";

    $fcont file_get_contents($file);

    ?>
    <html>
    <head>
    <title>This is the contents of your file!</title>
    </head>

    <? if($fcont) { ?>

    The file <? echo $file?> has been read successfully. Here are it's contents:<br><br>

    <? echo $fcont;

    ?>
    Something like that?
    OMFG SitePoint ROXORZ TEH BIG ONE111!
    Wish you were invisible?

  5. #5
    SitePoint Member
    Join Date
    Feb 2006
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you all for your help
    I have some questions...
    1. How can i look inside a folder and open and read each .txt file without knowing their names?
    2. The files will be .txt files. The headers of the news will be at the first lines and the other lines will be the contents of the news? I mean how can i seperate them? In your examples, you are assigning the whole content to one variable...
    3. Which tutorial(s) do you advise me to read (with examples i prefer) to learn php?

    Thank you very much


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •