ignoring comment line on the text file.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ogo796
    New Member
    • Jan 2008
    • 44

    ignoring comment line on the text file.

    hi everyone
    i am reading file from text file to the input box so my problem i cant read the commented file.so if someone can help me with to ignore lines with hash i will be glad.

    #8542 sinah 34 - 08 -55
  • nathj
    Recognized Expert Contributor
    • May 2007
    • 937

    #2
    Originally posted by ogo796
    hi everyone
    i am reading file from text file to the input box so my problem i cant read the commented file.so if someone can help me with to ignore lines with hash i will be glad.

    #8542 sinah 34 - 08 -55
    Hi,

    Could you post the code you have so far? Then I will have a go and suggesting an alteration to do this for you.

    Cheers
    nathj

    Comment

    • ogo796
      New Member
      • Jan 2008
      • 44

      #3
      hi People
      -------------
      books .txt
      -------------
      to sir with love
      the punisher
      #php Bible

      this is text file that i am reading from.i read these files into an array after that i wipe the content of the file after i push the content of the file to the
      text file line by line cause i want to write the specific line and sort.

      so my problem is when i write bag to the text file it push all the commented file at the bottom of the file and this prevent me to read the file after the commented one so anybody help
      thanks
      example
      $your_data = $_POST["book"]
      $q=$_POST["path"];

      $myArray = file($q."book.t xt");

      //Open registry file and wipe contents

      $fp = fopen($q."book. txt", "w");

      array_push($myA rray,$your_data );

      usort($myArray, "strnatcmp" );



      //Loop through the registry array

      foreach ($myArray as $value)

      {

      //Write the sorted contents to registry line-by-line

      fwrite($fp,$val ue);



      }



      // Close the registry file

      fclose($fp);

      please help me to ignore the commented file.

      Comment

      Working...