SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jan 2005
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    help needed, weird php compiler problem

    Ok heres the problem, I have a script that parses a file that is 2500 lines long with 300 tab delimited fields on each.

    The problem is, that I am not able to put it all into an array.

    PHP Code:
    $file file($_SERVER['DOCUMENT_ROOT'].'/tmp/listdata.txt');
    $lines count($file);
    $stack = array();
    // Seperate the lines into an array
    for ($i=0$i<$lines$i++) {
        
    $stack[$i] = explode("\t"$file[$i]);
    }
    // for
    print 'done'
    When I run this, php returns nothing. No error, nothing. If I remove:
    $stack[$i] = explode("\t", $file[$i]);

    it works, but if I add it, it doesnt.

    Thank

  2. #2
    SitePoint Member
    Join Date
    Jan 2005
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The most weird problem, it went away by changing those lines to:

    $file = file($_SERVER['DOCUMENT_ROOT'].'/tmp/listdata.txt');
    $lines = count($file);
    $stack = array();
    $array = array();
    for ($i=0; $i<5; $i++) {
    $array = explode("\t", $file[$i]);
    foreach ($array as $key => $value) {
    $array[$key] = addslashes($value);
    }
    $stack[$i] = $array;
    }// for


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
  •