[英]Adding + between keywords PHP
在我的標簽雲中,我的網址看起來像這樣
../search.php?query=cat&select=all
../search.php?query=the cat&select=all
我想做的是,如果關鍵字是多個單詞,例如:
../search.php?query=the cat&select=all
在這樣的單詞之間加上一個+
../search.php?query=the+cat&select=all
我的默認搜索功能在表單執行的搜索中使用+
,但我也希望標簽雲具有相同的功能。 我這樣做只是為了外觀。 它按原樣工作得很好,但是我想我還是會問。 有人可以幫忙嗎? 這是我當前用於標簽雲中鏈接的內容
echo " <a href='../search.php?query=$word&select=all' target='rel' title='".($word)."'>".($word)."</a>";
謝謝。
我認為您正在尋找的是urlencode()函數。
urlencode
和urldecode
只是您需要的功能。
echo " <a href='../search.php?query=".urlencode($word)."&select=all' target='rel' title='".($word)."'>".($word)."</a>";
在另一頁上,您可以使用urldecode
echo urldecode($_GET['query']);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.