【发布时间】:2019-08-20 09:44:04
【问题描述】:
我有一个这样的关联链接数组
$my_links = [
'city 1' => 'http://link1',
'city 2' => 'http://link2',
'Head Office' => 'http://link3'
];
还有一些像这样的html。 html由脚本动态生成(wordpress博客内容)。
<p>
You can visit our stores at City 1
and City 2,
or visit our Head office.
</p>
必需的输出:使用上述array 的索引制作可点击链接
<p>
You can visit our stores at <a href="http://link1">City 1</a>
and <a href="http://link2">City 2</a>,
or visit our <a href="http://link3">Head office</a>.
</p>
如何使用PHP 和/或JQuery 实现此目的?
【问题讨论】:
-
这样做
<p> You can visit our stores at <a href="<?php echo $my_links['city 1'];?>">City 1</a> and <a href="<?php echo $my_links['city 2'];?>">City 2</a>, or visit our <a href="<?php echo $my_links['Head Office'];?>">Head office</a>. </p> -
感谢您的快速回复和编辑。 html 由脚本动态生成(来自 wordpress 博客内容)。更新了我的问题。
标签: php jquery arrays wordpress hyperlink