且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

PHP-如何打印此多维数组?

更新时间:2023-02-23 17:52:32

(最困难的部分)是获取一维数组的键,这是使用以下方法获得的:

The (most) difficult part is getting the key of the first dimension array, this is get using:

$key=>$data

在foreach中.

$ key表示要遍历的数组的键. $ data的内容,在您的示例中,$ data包含第二维数组.

$key represents the key of the array being traversed. $data the content, in your example $data contains the second dimension array.

foreach( $array AS $key=>$data )
{
   echo '<a href="'.urldecode( $data['link'] ).'">'.$data['title'].' - '.$key.'</a><br>';
}

有关foreach语句的更多信息: http://php.net/manual/zh-CN/control-structures.foreach.php

More info about the foreach statement: http://php.net/manual/en/control-structures.foreach.php