douzhuo6931 2016-02-13 08:51
浏览 30
已采纳

连接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

  • 写回答

1条回答 默认 最新

  • doumu5023 2016-02-13 09:22
    关注

    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">
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 模电中二极管,三极管和电容的应用
  • ¥15 关于模型导入UNITY的.FBX: Check external application preferences.警告。
  • ¥15 气象网格数据与卫星轨道数据如何匹配
  • ¥100 java ee ssm项目 悬赏,感兴趣直接联系我
  • ¥15 微软账户问题不小心注销了好像
  • ¥15 x264库中预测模式字IPM、运动向量差MVD、量化后的DCT系数的位置
  • ¥15 curl 命令调用正常,程序调用报 java.net.ConnectException: connection refused
  • ¥20 关于web前端如何播放二次加密m3u8视频的问题
  • ¥15 使用百度地图api 位置函数报错?
  • ¥15 metamask如何添加TRON自定义网络