doukeng7426 2018-04-11 10:37
浏览 45
已采纳

php - 如何在刀片中设置href url

I'm currently working with Laravel (because my school told me to) and php and I really don't get it. I'm working with blade.php which recieves values from a ViewControlle(not quite if it works like this but I think so). The value contains name and and a url for wikipedia which leads to the right article for the name in a table.

So what I'm trying to accomplish is

<a href="https://en.wikipedia.org/wiki/Berlin">Berlin</a>

So my code is currently:

@foreach($cities as $city)
<td>
<tr><a href="{{$city["Url"]}}">{{$city["Name"]}}</a></tr>
</td>
@endforeach

and it does not work while

@foreach($cities as $city)
<td>
<tr>{{$city["Name"]}}</tr>
</td>
@endforeach

works perfectly fine...

I've already searched for an answer but all answers are written for php with

echo '...';

I really don't get it.

Thanks in advance ^^

  • 写回答

2条回答 默认 最新

  • dongmi4809 2018-04-11 11:04
    关注

    change

    <tr><a href="{{$city["Url"]}}">{{$city["Name"]}}</a></tr>
    

    to

     <tr><a href="{{$city['Url']}}">{{$city["Name"]}}</a></tr>
    

    or you can do it like this:

    <tr><a href='{{$city["Url"]}}'>{{$city["Name"]}}</a></tr>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!