
May 9th, 2003, 09:21 PM
|
|
Guest
|
|
Posts: n/a
Time spent in forums:
Reputation Power:
|
|
foreach will only loop though the elements of the selected array
if you want to display all the dimentions of an array use the function
print_r($array);
if you only want to print out certain parts of an array, you could use this function
PHP Code:
function PrintArray($array)
{
if(is_array($array))
{
foreach($array as $key=>$value)
{
if(is_array($value)
{
// the value of the current array is also a array, so call this function again to process that array
PrintArray($value)
}
else
{
// This part of the array is just a key/value pair
echo "$key: $value<br>";
}
}
}
}
that will do the same as print_r(); however you can then limit what is printed by placing some conditions where i have the line
echo "$key: $value<br>";
so you could change that to
if($key == $name)
{
echo "$key: $value<br>";
}
so now it will only print the array element when key == name
|