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条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?