duanque2413 2017-07-03 07:25
浏览 196
已采纳

Yii2如何在params.php中添加多个链接

I want to add multiple link in params.php . Is it possible to do so ?

Current view of my params in yii2 .

Params.php

<?php 
return [

"api_link" => "http://example.com" ,
];

I want to add multiple link in it 
Ex: 
<?php

return[
"api_link" => "http://example.com" & "http://www.example.com"

];

Is it possible to do so ? I tried but unable to succeed on this attempt .

Any lead over this will really be helpful.

  • 写回答

3条回答 默认 最新

  • drwiupraq047311240 2017-07-03 08:56
    关注

    You can store in an array

    <?php 
       return [
        "api_link" => [
            "http://example.com",
              "http://example.com",
          ]
      ];
     ....
    

    and for accessing you must iterate over it

         $myaArray =  [
            "api_link" => [
                "http://example.com",
                "http://www.example.com",
            ]
        ];
    
        foreach( $myArray['api_link'] as $key =>$value){
          echo $value;
        }
    

    or

       echo $myArray['api_link'][0]; 
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 阿里云函数计算自定义层部署LibreOffice
  • ¥15 打开软件提示错误:failed to get wglChoosePixelFormatARB
  • ¥30 电脑误删了手机的照片怎么恢复?
  • ¥15 (标签-python|关键词-char)
  • ¥15 python+selenium,在新增时弹出了一个输入框
  • ¥15 苹果验机结果的api接口哪里有??单次调用1毛钱及以下。
  • ¥20 学生成绩管理系统设计
  • ¥15 来一个cc穿盾脚本开发者
  • ¥15 CST2023安装报错
  • ¥15 使用diffusionbert生成文字 结果是PAD和UNK怎么办