It's possible to use comma's in URLs for example: ?page=$page&id=120
Instead of AND (&) we use comma
?page=$page,id=120
6 6478 Atli 5,058
Expert 4TB
That should work fine. A comma is not a special char in URLs so it should come through as a part of the "page" value.
Can you give me an example for this to replace & (and) with , (comma)
as far as I know, this needs your server to rewrite the url containing commas back into ampersands. in contrast to & (parameter separator), the comma does not have a special meaning. otherwise you’ll only get one URL parameter (page).
Or, you could convert it in PHP. - if (!empty($_GET) && count($_GET) == 1) {
-
$query_vars = array();
-
$query_data = explode(',', current($_GET));
-
-
if (!empty($query_data)) {
-
$query_vars[key($_GET)] = array_shift($query_data);
-
-
foreach ($query_data as $query_pair) {
-
if (!empty($query_pair)) {
-
$query_pair = explode('=', $query_pair, 2);
-
-
if (count($query_pair) == 1) {
-
$query_vars[$query_pair[0]] = null;
-
} else {
-
$query_vars[$query_pair[0]] = $query_pair[1];
-
}
-
}
-
}
-
}
-
-
$_GET = $query_vars;
-
}
Untested.
I found this idea interesting, and decided to write something a bit more concrete to solve your problem. I've explained it in more detail here. - /**
-
* Rebuild the superglobal $_GET array
-
*
-
* @param string $query_string The query string
-
* @param string $ampersand The replacement for ampersands in the query string
-
* @param string $equality The replacement for equality signs in the query string
-
* @return void
-
*/
-
function rebuild_get($query_string, $ampersand = '&', $equality = '=') {
-
if (!empty($query_string)) {
-
// Empty the $_GET array
-
$_GET = array();
-
-
// Insert key => value pairs into the $_GET array
-
foreach (explode($ampersand, $query_string) as $pair) {
-
$pair_data = explode($equality, $pair, 2);
-
$_GET[$pair_data[0]] = (count($pair_data) > 1) ? $pair_data[1] : null;
-
}
-
}
-
}
Why do you want to use a comma instead of an ampersand? AFAIK, the valid separators are ampersands (&) and semi-colons (;).
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Howard Brazee |
last post by:
I would like to click on a URL of a html document that will open several URLs at
once for me.
Does someone have an example of a html document that will do this?
|
by: DM |
last post by:
I'm working on a site with more than 1700 HTML files. We'll be moving files
around on this site a lot because we're reorganizing it. I'm thinking of writing
a script that will convert all URLs in...
|
by: AES |
last post by:
Encountered a URL containing a comma the other day -- the first time
I've ever noticed that, so far as I can recall. It worked fine,
however, and I gather commas are legal in URLs.
Out of...
|
by: Shawn Odekirk |
last post by:
Some code I have inherited contains a macro like the following:
#define setState(state, newstate) \
(state >= newstate) ? \
(fprintf(stderr, "Illegal...
|
by: siliconwafer |
last post by:
Hi,
In case of following expression:
c = a && --b;
if a is 0,b is not evaluated and c directly becomes 0.
Does this mean that && operator is given a higher precedence over
'--'operator?
as...
|
by: Wayne |
last post by:
I have the following string:
"smith", "Joe", "West Palm Beach, Fl."
I need to split this string based on the commas, but as you see the city
state contains a comma. String.split will spilt the...
|
by: Lighter |
last post by:
In 5.3.3.4 of the standard, the standard provides that "The lvalue-to-
rvalue(4.1), array-to-pointer(4.2),and function-to-pointer(4.3)
standard conversions are not applied to the operand of...
|
by: WebCM |
last post by:
How to apply nice URL-s into CMS?
1. Should we use nice urls for every page?
2. Do we need to put a FULL path into <a href="">?
3. What is faster and better?
a) 10 rules in .htaccess...
|
by: Hermann |
last post by:
I run a server with apache 1.3 and php 5.
Yesterday I notice that sometimes the HTTP_HOST server variable has a
comma separated list in it.
Let's say my domain name is: www.mydomain.com
Usually...
|
by: kshw |
last post by:
Hi,
I’m new to programming. I’m currently learning python to write a web crawler to extract all text from a web page, in addition to, crawling to further URLs and collecting the text there. The...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |