shorten array handling

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • tarscher@gmail.com

    shorten array handling

    Hi all,

    Is it possible to put this in one line?

    $nodes[0][0] = $row[0];
    $nodes[0][1] = $row[1];
    $nodes[0][2] = $row[2];

    Thanks

    tarscher

  • Janwillem Borleffs

    #2
    Re: shorten array handling

    tarscher@gmail. com wrote:[color=blue]
    > Is it possible to put this in one line?
    >
    > $nodes[0][0] = $row[0];
    > $nodes[0][1] = $row[1];
    > $nodes[0][2] = $row[2];
    >[/color]

    Sure:

    $nodes[0] = array_slice($ro w, 0, 3);


    JW


    Comment

    • Chung Leong

      #3
      Re: shorten array handling

      $nodes[0] = array($row[0], $row[1], $row[2]);

      or if every element in $row will go into $nodes:

      $nodes[0] = $row;

      Comment

      Working...