如何将 link 添加到 php 中的列表
How to add a link to a list in php
您好,我有一个 Api 列表,它是使用 php 生成的,这里是用于生成列表的代码
<html>
<title> API LIST</title>
<body>
<?php
$jsondata = file_get_contents("api_link");
$json = json_decode($jsondata, true);
$output = "<ul>";
foreach($output['A'] as $schools){
$output .= "<li>".$schools['name']."</li>";
}
$output .="</ul>";
echo $output;
?>
列表已成功填充,但我如何才能将 link 添加到列表中,以便当用户单击其中一项时,它会打开一个特定的 linked 页面,方法如下我试过了
$output .= "<li <a href="www.google.com/name"></a>".$schools['name']."</li>";
$output .= "<li>".$schools['name']. <a href="www.google.com/name"></a>"</li>";
$output .= "<li>".$schools['name']."<a href="www.google.com/name"></a></li>";
我不知道在哪里或如何添加 a href 代码
使用
$output .= '<li><a href="www.google.com/name">'.$schools['name'].'</a></li>';
你只需要在你的 code.You 上做一些改变就可以尝试
$output .= '<a href=https://www.google.com'.$schools['name'].'><li>'.$schools['name'].'</li></a>';
根据评论,您可以使用 .
连接(连接)php 中的 string
和 variable
。
您好,我有一个 Api 列表,它是使用 php 生成的,这里是用于生成列表的代码
<html>
<title> API LIST</title>
<body>
<?php
$jsondata = file_get_contents("api_link");
$json = json_decode($jsondata, true);
$output = "<ul>";
foreach($output['A'] as $schools){
$output .= "<li>".$schools['name']."</li>";
}
$output .="</ul>";
echo $output;
?>
列表已成功填充,但我如何才能将 link 添加到列表中,以便当用户单击其中一项时,它会打开一个特定的 linked 页面,方法如下我试过了
$output .= "<li <a href="www.google.com/name"></a>".$schools['name']."</li>";
$output .= "<li>".$schools['name']. <a href="www.google.com/name"></a>"</li>";
$output .= "<li>".$schools['name']."<a href="www.google.com/name"></a></li>";
我不知道在哪里或如何添加 a href 代码
使用
$output .= '<li><a href="www.google.com/name">'.$schools['name'].'</a></li>';
你只需要在你的 code.You 上做一些改变就可以尝试
$output .= '<a href=https://www.google.com'.$schools['name'].'><li>'.$schools['name'].'</li></a>';
根据评论,您可以使用 .
连接(连接)php 中的 string
和 variable
。