Web Analytics Made Easy -
StatCounter Need to Parse a tab -delimited file and fill a List Box - CodingForum


No announcement yet.

Need to Parse a tab -delimited file and fill a List Box

  • Filter
  • Time
  • Show
Clear All
new posts

  • Need to Parse a tab -delimited file and fill a List Box

    The problem I have in hand is divided into three steps
    1.Load a text file
    2.Parse the text file and get the first row attributes
    3.Display the attribues one after the other in a List Box

    Could some one please help me on this

    Appreciate your time.

  • #2
    Does all the textfile data have to be on one line? becuase if you could have a linebreak between each of them it would be simple:

    PHP Code:
    $file file("file.txt"); // open file and breaks it into an array by newlines 
    // basically, each new line in the file will be a new value in the array
    $list '<select name="name">'// set a variable to store some html data
    for($i=0;$i<count($file);$i++){ // start a loop to go through each value in the array
    $list .= '<option value="value" name="name">'.$file[$i].'</option>'// add data to the variable using .=  
    // end for loop
    $list .= '</select>'// finish select tag
    echo $list// print the HTML to the page 
    If you cannot do it this way, could you please give som more information about how the file is spaced out. (eg, comma separated)
    PHP Weekly - A PHP Developers Resource
    PHP 5.1.4 and Ruby on Rails web hosting
    Moderator of PHP and Work offers and Requests
    Install Apache/PHP/MySQL
    (by marek_mar) | TinyPlugin Architecture


    • #3


      • #4
        Thanks for the prompt reply.I was wondering how the code would change if the uploaded file where to be an Excel file.(or for that matter any kind of file provided it is tab-delimited).

        Do I have to take any special care while loading different kinds of formats.The form expects any kind of files as long as they are tab -delimited

        Appreciate your time