我的问题是你如何连接para1和para2,并在PHP中显示web1数组中每个数据的url中的图像?
这是我想要的一个例子。
来自网址:www.example.com/jferf0923i092eijodsojs
请记住,这些网址只是我想要实现的一个例子。
{"Web 1": {
"url1": {
"para1": "www.example.com",
"para2": /jferf0923i092eijodsojs,
},
"url2": {
"para1": "www.example.com",
"para2": asjdoisadj829332oijd,
},
"url3": {
"para1": "www.example.com",
"para2": assasdijoj21389445,
}
}}
感谢您的帮助!干杯
答案 0 :(得分:1)
我认为这大致是你正在寻找的,至少它应该给你一个开始:
<?php
$catalog = [
"Web 1" => [
"url1" => [
"para1" => "www.example.com",
"para2" => "jferf0923i092eijodsojs",
],
"url2" => [
"para1" => "www.example.com",
"para2" => "asjdoisadj829332oijd",
],
"url3" => [
"para1" => "www.example.com",
"para2" => "assasdijoj21389445",
]
]
];
foreach ($catalog as $entry) {
foreach ($entry as $url) {
$imageUrl = sprintf('https://%s/%s', $url['para1'], $url['para2']);
echo '<img src="' . $imageUrl . '">'."\n";
}
}
输出是有效的html,并且在html页面中使用时应该可视化图像:
<img src="https://www.example.com/jferf0923i092eijodsojs">
<img src="https://www.example.com/asjdoisadj829332oijd">
<img src="https://www.example.com/assasdijoj21389445">