将 URL 与分隔的关键字关联起来
我有一个变量 $keywords
这个变量的内容是用逗号或空格分隔的单词 例如:
$keywords= key1,key2,key3
或者
$keywords=key1 key2 key3
我拥有的表是:
<table width="500" border="1">
<tr>
<td height='auto'>Keywords: $keywords</td>
</tr>
</table>
我想在 key1 key2 key3 中爆炸 $keywords
... 并将每个分隔的单词关联到一个预定义的 URL:
http://miosite.com/search/label/key1
http://miosite.com/search/label/key2
http://miosite.com/search/label/key3
所以我想得到这个:
<table width="500" border="1">
<tr>
<td height='auto'>Keywords: key1,key2,key3</td>
</tr>
</table>
在哪里
key1=http://miosite.com/search/label/key1
key2=http://miosite.com/search/label/key2
key1=http://miosite.com/search/label/key3
如何?
I have a variable $keywords
The content of this variable are words separated by commas or spaces
for example:
$keywords= key1,key2,key3
Or
$keywords=key1 key2 key3
the table that I have is:
<table width="500" border="1">
<tr>
<td height='auto'>Keywords: $keywords</td>
</tr>
</table>
I want explode $keywords
in key1 key2 key3 ...
And associate to each separated word a predifined URL:
http://miosite.com/search/label/key1
http://miosite.com/search/label/key2
http://miosite.com/search/label/key3
So I want get this:
<table width="500" border="1">
<tr>
<td height='auto'>Keywords: key1,key2,key3</td>
</tr>
</table>
Where
key1=http://miosite.com/search/label/key1
key2=http://miosite.com/search/label/key2
key1=http://miosite.com/search/label/key3
How to?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以检查逗号以确定要分解的分隔符,然后再次将字符串组合在一起:
编辑:显然目标是删除站点地址,而不是添加它......没有人知道这一点。新代码:
有点骇人听闻,但请尝试一下。
编辑:哦,现在他们需要链接吗?哈哈
好的,试试吧。
You could check for the comma to determine which delimiter to explode on, then put together the string again:
EDIT: Apparently the object is to REMOVE the site address, not add it... no one figured that out. new code:
Hackish, but give that a shot.
Edit: Oh now they need to be linked? LOL
Ok, try that out.
关键词:
Keywords:
我只是在 html 和 html 中通过 embeddg php 重写。采取的是您的链接之间的逗号:
Iam just rewrting by embeddg php within html & taken are of caommas between your links: