PHP数组学习(三)

利用foreach对数组进行输出

一维数组:

$name =array( 0=>"Ann",1=>"Blue",2=>"Joe");
foreach($name as $value)
{
	echo "Value: " . $value . "<br />";
}

二维数组:

$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 />";
	}
}

你可能感兴趣的:(PHP,入门,数组)