Php 如何显示此多维数组中的值?
如何从这个给定数组接收图像url并显示在图像标记中?从下面的数组中,您将获得所需的所有输入。此值从数据库检索并存储在数组变量中。我想使用wordpress循环显示此数组中的值Php 如何显示此多维数组中的值?,php,wordpress,multidimensional-array,advanced-custom-fields,Php,Wordpress,Multidimensional Array,Advanced Custom Fields,如何从这个给定数组接收图像url并显示在图像标记中?从下面的数组中,您将获得所需的所有输入。此值从数据库检索并存储在数组变量中。我想使用wordpress循环显示此数组中的值 array(4) { [0]=> array(18) { ["ID"]=> int(32) ["id"]=> int(32) ["title"]=> string(15) "President Image" ["filename"]=&
array(4) {
[0]=>
array(18) {
["ID"]=>
int(32)
["id"]=>
int(32)
["title"]=>
string(15) "President Image"
["filename"]=>
string(11) "3f666ad.jpg"
["url"]=>
string(63) "http://localhost/moderna/wp-content/uploads/2015/08/3f666ad.jpg"
["alt"]=>
string(15) "President Image"
["author"]=>
string(1) "1"
["description"]=>
string(0) ""
["caption"]=>
string(17) "This is a caption"
["name"]=>
string(7) "3f666ad"
["date"]=>
string(19) "2015-08-25 05:18:16"
["modified"]=>
string(19) "2015-08-31 14:05:45"
["mime_type"]=>
string(10) "image/jpeg"
["type"]=>
string(5) "image"
["icon"]=>
string(61) "http://localhost/moderna/wp-includes/images/media/default.png"
["width"]=>
int(200)
["height"]=>
int(200)
试试这个:
echo $result[0]['url'];
如果它有许多索引,请使用foreach
$ImgArr = [];
foreach($result as $key => $val){
$ImgArr[] = $val['url'];
}
print_r($ImgArr');
$array[0]['url']
将给出图像的url
,并在循环中foreach($k=>$v){$v['url'];}