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 请问Ubuntu要怎么安装chrome呀?
  • ¥15 视频编码 十六进制问题
  • ¥15 Xsheii7我安装这个文件的时候跳出来另一个文件已锁定文件的无一部分进程无法访问。这个该怎么解决
  • ¥15 unity terrain打包后地形错位,跟建筑不在同一个位置,怎么办
  • ¥15 FileNotFoundError 解决方案
  • ¥15 uniapp实现如下图的图表功能
  • ¥15 u-subsection如何修改相邻两个节点样式
  • ¥30 vs2010开发 WFP(windows filtering platform)
  • ¥15 服务端控制goose报文控制块的发布问题
  • ¥15 学习指导与未来导向啊