...

View Full Version : Display parts of an array



tomharto
08-22-2011, 05:57 AM
I have this array


$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?

MarPlo
08-22-2011, 08:37 AM
Hy
Try this code:


foreach($users as $k=>$v) {
echo '<br/>key = '. $k. ' , val = '. $v;
}

tomharto
08-22-2011, 01:16 PM
I've tried that before and that just echoes key - 0 and val - Array :(

tomharto
08-22-2011, 02:16 PM
Sorted it, i really should stop trying to code at 5am :P


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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum