Results 1 to 3 of 3

Thread: Display the 2nd value of each array in a multidimensional array

  1. #1
    Join Date
    Dec 2005
    Posts
    9
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Display the 2nd value of each array in a multidimensional array

    I have this multidimensional array. How can I display all the value of, for example, [1]? So I would get 671, 1, and Standard.

    PHP Code:
    Array
    (
    [
    id] => Array
      (
      [
    0] => 546
      
    [1] => 671
      
    [2] => 983
      
    )
    [
    quant] => Array
      (
      [
    0] => 5
      
    [1] => 1
      
    [2] => 7
      
    )
    [
    notes] => Array
      (
      [
    0] => Heck Yes
      
    [1] => Standard
      
    [2] => None
      
    )

    Thanks

  2. #2
    Join Date
    Jul 2008
    Posts
    199
    Thanks
    6
    Thanked 58 Times in 57 Posts

    Default

    PHP Code:
    foreach($arr as $item){
      echo 
    $item[1];


  3. #3
    Join Date
    Apr 2009
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    PHP Code:
    <?php
    $People
    [0][1] = 546;
    $People[0][2] = 671;
    $People[0][3] = 983;
    $People[1][1] = 5;
    $People[1][2] = 1;
    $People[1][3] = 7;
    $People[2][1] ="Heck Yes";
    $People[2][2] = "Standard";
    $People[2][3] = "None";
    //echo sizeof($People);
    for($i 0$i sizeof($People); $i++)
    {
    for(
    $j 0$j 1$j++)
    print 
    $People[$i][2] . "<br>";
    }

    ?>
    Last edited by Snookerman; 04-21-2009 at 06:19 AM. Reason: added [php] tags

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
  •