【发布时间】:2013-11-05 19:09:25
【问题描述】:
您好,我有以下搜索表单:
<form method='get'><input type='text' name='searchvalue' value='<? if (isset($_GET['searchvalue'])) echo $_GET['searchvalue'];?>' /> <input type='submit' value='Search' /><input type='hidden' name='pagenum' value='1' /></form>
它是访问API并返回搜索结果的wordpress插件的一部分,当我将搜索数据发送到api时,file_get_contents("$api_url/book/index.php/name/$searchvalue?key=$api_key");查询,如果它有空格,需要这样格式化:This%20Is%20An%20Example相反,它的格式如下:This+Is+An+Example
我打算使用str_replace() 替换加号:str_replace("+", "%20", $searchvalue);,但它似乎不起作用!
有什么建议吗?
【问题讨论】:
标签: php string wordpress search replace