连接URL并在URL中显示图像PHP [关闭]

问题描述:

my question is how do you concatenate para1 and para2, and displays the image that is in the url for each of the data in the web1 array in PHP?

Here is an example of what I wanted.

From url1: www.example.com/jferf0923i092eijodsojs

Please keep in mind that these urls are just an example of what I want to achieve.

{"Web 1": {
      "url1": {
        "para1": "www.example.com",
        "para2": /jferf0923i092eijodsojs,
      },
      "url2": { 
        "para1": "www.example.com",
        "para2": asjdoisadj829332oijd,
      },
      "url3": {
        "para1": "www.example.com",
        "para2": assasdijoj21389445,
      }
      }}  

I appreciate your help! Cheers

我的问题是你如何连接para1和para2,并显示每个的url中的图像 这是我想要的一个例子。 p> / p>

请记住,这些网址只是我想要实现的一个例子。 p>

  {“Web 1”:{\  n“url1”:{
“para1”:“www.example.com”,
“para2”:/ jferf0923i092eijodsojs,
},
“url2”:{
“para1”:“www.example  .com“,
”para2“:asjdoisadj829332oijd,
},
”url3“:{
”para1“:”www.example.com“,
”para2“:assasdijoj21389445,
} 
  }} 
  code>  pre> 
 
 

感谢您的帮助! 干杯 p> div>

I assume this is roughly what you are looking for, at least it should give you a start:

<?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 . '">'."
";
    }
}

The output is valid html and should visualize the image when used inside an html page:

<img src="https://www.example.com/jferf0923i092eijodsojs">
<img src="https://www.example.com/asjdoisadj829332oijd">
<img src="https://www.example.com/assasdijoj21389445">