如何显示这个多维数组的值?
How can display value from this multidimensional array?
如何从这个给定数组接收图像 url 并显示在图像标签内?从下面的数组中,您将获得所需的所有输入。该值从数据库中检索并存储在数组变量中。我想使用 wordpress loop
显示这个数组的值
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');
如何从这个给定数组接收图像 url 并显示在图像标签内?从下面的数组中,您将获得所需的所有输入。该值从数据库中检索并存储在数组变量中。我想使用 wordpress loop
显示这个数组的值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');