mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-07-11 21:52:12 +00:00
Development
- Changed from http_build_query to custom solution as it doesn't support querystrings with "%" on some php versions.
This commit is contained in:
@@ -301,6 +301,28 @@ class RouterBase {
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function httpBuildQuery(array $input) {
|
||||||
|
|
||||||
|
$output = '';
|
||||||
|
|
||||||
|
if(count($input)) {
|
||||||
|
|
||||||
|
$output .= '?';
|
||||||
|
|
||||||
|
$i = 0;
|
||||||
|
foreach ($input as $key => $value) {
|
||||||
|
$output .= $key . '=' . urlencode($value);
|
||||||
|
if (($i + 1) < count($input)) {
|
||||||
|
$output .= '&';
|
||||||
|
}
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
public function arrayToParams(array $getParams = null, $includeEmpty = true) {
|
public function arrayToParams(array $getParams = null, $includeEmpty = true) {
|
||||||
|
|
||||||
if(is_array($getParams)) {
|
if(is_array($getParams)) {
|
||||||
@@ -310,7 +332,7 @@ class RouterBase {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return http_build_query($getParams);
|
return $this->httpBuildQuery($getParams);
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
@@ -461,8 +483,8 @@ class RouterBase {
|
|||||||
|
|
||||||
$url = '/' . trim(join('/', $url), '/') . '/';
|
$url = '/' . trim(join('/', $url), '/') . '/';
|
||||||
|
|
||||||
if($getParams !== null && count($getParams)) {
|
if($getParams !== null) {
|
||||||
$url .= '?' . $this->arrayToParams($getParams);
|
$url .= $this->arrayToParams($getParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $url;
|
return $url;
|
||||||
|
|||||||
Reference in New Issue
Block a user