Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jul 2010
    Location
    Sheffield
    Posts
    822
    Thanks
    93
    Thanked 18 Times in 18 Posts

    Display parts of an array

    I have this array

    PHP Code:
    $users[] = array("".$row['fuserid']."" => $row['fname'].$row['fname']); 
    I need to display the fuserID and fname from the array, but im not sure how i would do it, can anyone help?

  • #2
    Regular Coder
    Join Date
    Mar 2011
    Posts
    148
    Thanks
    0
    Thanked 20 Times in 20 Posts
    Hy
    Try this code:
    Code:
    foreach($users as $k=>$v) {
    echo '<br/>key = '. $k. ' , val = '. $v;
    }

  • #3
    Regular Coder
    Join Date
    Jul 2010
    Location
    Sheffield
    Posts
    822
    Thanks
    93
    Thanked 18 Times in 18 Posts
    I've tried that before and that just echoes key - 0 and val - Array

  • #4
    Regular Coder
    Join Date
    Jul 2010
    Location
    Sheffield
    Posts
    822
    Thanks
    93
    Thanked 18 Times in 18 Posts
    Sorted it, i really should stop trying to code at 5am :P

    PHP Code:
        foreach ($users as $key => $value
            {
                foreach (
    $value as $k => $v)
                {
                    echo 
    "Key 2: $k; Value 2: $v<br />\n";
                }
            } 


  •  

    Posting Permissions

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