Results 1 to 8 of 8

Thread: [resolved, i think]Array inside an Array...

  1. #1

    Thread Starter
    Fanatic Member ALL's Avatar
    Join Date
    Jul 2004
    Location
    192.168.1.1
    Posts
    711

    [resolved, i think]Array inside an Array...

    ok, i am helping someone out with some php code, but i cannot figure out how to put an array inside an array, i know how to do it in CGI but not php, here is the code:
    PHP Code:
    <table width="175" height="1" border="0" cellpadding="0" cellspacing="0" class="left">
    <tr>
    <td height="1" background="images/left_border.gif"><img src="images/spacer" width="175" height="1"></td>
    </tr>
    <tr>
    <td align="center" valign="top">
    <img src="images/left_rule.gif" width="170" height="1" vspace="3"></td>
    </tr><?
    $dir = 'images/left/';
    $dh = opendir($dir);

    while (false !== ($filename = readdir($dh))) {
    if($filename == "Thumbs.db" || is_dir($filename)){
    }else{
    $files[] = $filename;
    }
    }
    $nooffildi = count($files);
    $nooffiles = ($nooffildi-1);
    srand((double)microtime()*100000);
    for($i=0; $i<=2; $i++){
    $randnum[$i] = rand(0,$nooffiles); 
    while($files[$randnum[$i]] == ""){
    $randnum[$i] = rand(0,$nooffiles);
    }
    //THIS LINE!!!
    ecno "<tr>\n
    <td align=\"center\" valign=\"top\"><img src=$dir" . //HERE>>// . "$files[$randnum[$i]]" . //<<HERE// . "width=\"175\" border=\"0\" class=\"iborder\"></td>\n
    </tr>\n
    <tr>\n
    <td align=\"center\" valign=\"top\"><img src=\"images/left_rule.gif\" width=\"170\" height=\"1\" vspace=\"3\"></td>\n
    </tr>\n";
    }
    echo "</table>\n";
    ALSO, ther //HERE// is only there to show you where i am taling about
    Last edited by ALL; May 16th, 2005 at 12:55 PM.
    Please support one of my projects?
    TKForums.com

    Web Forum
    JavaScript Wiki
    ________________________
    If somone helps you, please rate their post, by clicking the to rate their post

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Array inside an Array...

    What do you mean?
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  3. #3

    Thread Starter
    Fanatic Member ALL's Avatar
    Join Date
    Jul 2004
    Location
    192.168.1.1
    Posts
    711

    Re: Array inside an Array...

    he sayes it comes up with an error when on this statment:
    PHP Code:
    $files[$randnum[$i]] 
    i looked into it, and in php you are not allowed to use []'s inside []'s

    how can that be recodded to allow the Array $randnum (which contains numbers) to output the number into the Array $files.

    $files is a list of the files in a directory, and $randnum is an array of random numbers (only 3 rand nums)
    Please support one of my projects?
    TKForums.com

    Web Forum
    JavaScript Wiki
    ________________________
    If somone helps you, please rate their post, by clicking the to rate their post

  4. #4

    Thread Starter
    Fanatic Member ALL's Avatar
    Join Date
    Jul 2004
    Location
    192.168.1.1
    Posts
    711

    Re: Array inside an Array...

    wait, i think i found it; i should have used:
    PHP Code:
    {$files[$randnum[$i]]} 
    Please support one of my projects?
    TKForums.com

    Web Forum
    JavaScript Wiki
    ________________________
    If somone helps you, please rate their post, by clicking the to rate their post

  5. #5
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: [resolved, i think]Array inside an Array...

    That syntax is legal in PHP. What kind of error was it throwing?
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  6. #6

    Thread Starter
    Fanatic Member ALL's Avatar
    Join Date
    Jul 2004
    Location
    192.168.1.1
    Posts
    711

    Re: [resolved, i think]Array inside an Array...

    hmmm... here i will give a link to the thread where he asked:
    http://www.ahfb2000.com/webmaster_he...ead.php?t=4338

    butwe got it fixed
    Please support one of my projects?
    TKForums.com

    Web Forum
    JavaScript Wiki
    ________________________
    If somone helps you, please rate their post, by clicking the to rate their post

  7. #7
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: [resolved, i think]Array inside an Array...

    That is because:
    PHP Code:
    echo("$dir$files[$randnum[$i]]"); 
    Should be:
    PHP Code:
    echo("$dir{$files[$randnum[$i]]}"); 
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  8. #8

    Thread Starter
    Fanatic Member ALL's Avatar
    Join Date
    Jul 2004
    Location
    192.168.1.1
    Posts
    711

    Re: [resolved, i think]Array inside an Array...

    ya, that is what i found out, if you read the other pages, but thanks anway
    Please support one of my projects?
    TKForums.com

    Web Forum
    JavaScript Wiki
    ________________________
    If somone helps you, please rate their post, by clicking the to rate their post

Posting Permissions

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



Click Here to Expand Forum to Full Width