A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: php dynamic array names

  1. #1
    hi all,
    i have a couple of nested loops within my php script, and within the second loop i need to create a new array dynamically and put the value of an expression in it.

    the loops are: outer loop increments i by 1, inner loop increments j by 1.

    now, the dynamic array bit as i attampted it was:
    "$row".$i."[".$j."]"=$slicesxmax[$i]-$slicesxmin[$i];

    (clearly rubbish )

    what i am trying to do on the left hand side is:
    assign a value to (and therefore create) an array called
    $row, plus the value of i (e.g. $row1,$row2), and use the value of j to determine which slot in the array would be filled. the outcome would be something like:

    inner loop
    $row0[0]=
    $row0[1]=
    $row0[2]=
    (etc.)

    outer loop
    $row1[0]
    $row1[1]
    (etc.)

    hopefully this makes sense . i have experimented around and havent succeded in getting this to work, any ideas?

    thx in advance
    bob

  2. #2
    Registered User
    Join Date
    Feb 2001
    Posts
    13,041
    Hi,

    you can have multidimensional arrays...
    $row = array();
    $row[0] = array(3, 4, 5);
    print $row[0][1];
    You should probably create the subarrays like this
    $row = array();
    $row[0] = array();
    $row[1] = array();

    Musicman

  3. #3
    Senior Member
    Join Date
    Jul 2000
    Posts
    218
    Nice. There's a great article on array manipulation at DevShed:
    http://www.devshed.com/Server_Side/P...nip/page1.html

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

HTML5 Development Center