PHP配列学習(三)


foreachによる配列の出力
1次元配列:
$name =array( 0=>"Ann",1=>"Blue",2=>"Joe");
foreach($name as $value)
{
	echo "Value: " . $value . "<br />";
}

2 D配列:
$families = array
(
	"Ann" => array
		(
			"father" =>"Ann'father",
			 "mother" =>"Ann'mother",
			 "self" => "Ann"
		),
	"Blue" =>array
		( 
			"father" => "Blue'father",
			"mother" => "Blue'mother",
			"self" =>"Blue"
		),
	"Joe" =>array
		( 
			"father" => "Joe'father",
			"mother" => "Joe'mother",
			"self" =>"Joe"
		),
);

foreach($families as $temp)
{
	foreach($temp as $value)
	{
		echo "Value: " . $value . "<br />";
	}
}