I have one method in controller that receive several parameters:
public function api(){
$url_params = $this->uri->segment_array();
//...
}
and this is example of URL:
http://testsite.com/services/api/invite-businesses/contact_name/_testing/message/some%20message/url/some_URL/
So my array seems like:
array(10) {
[1]=>
string(8) "services"
[2]=>
string(3) "api"
[3]=>
string(17) "invite-businesses"
[4]=>
string(12) "contact_name"
[5]=>
string(12) "_testing"
[6]=>
string(7) "message"
[7]=>
string(14) "some%20message"
[8]=>
string(3) "url"
[9]=>
string(4) "some_URL"
}
You can see that one of parameters has space: some%20message
.
But I want to get real value, ae some message
. The value might contain any other character that URL converts to %xx
.
How to get real value
Use urldecode() to decode string
...
$url_params = $this->uri->segment_array();
foreach($url_params as &$param) {
$param = urldecode($param);
}
...
使用urldecode()解码URL编码的字符串
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.