[英]Regex to turn query string into slashes and values
What would be the regex in PHP for turning: PHP中用于转弯的正则表达式是什么:
?take=2&skip=0&page=1&pageSize=2&comment=the%20comment
Into: 进入:
/2/0/1/2/the%20comment
Thanks, I did the following: 谢谢,我做了以下工作:
$qPos = strpos($url, '?') ;
$queryString = substr($url, $qPos+1) ;
parse_str($queryString, $params) ;
foreach($params as $param) {
$pString .= '/'.$param ;
}
$url = substr($url, 0, $qPos).$pString ;
echo $url ;
Can't you use the $_GET variable? 您不能使用$ _GET变量吗? Eg:
例如:
$name = $_GET['name'];
$skip = $GET['skip'];
$str = $name . " " . $skip etc etc
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.