so here is the case:
i have a string in php (containts 2 words):
windows "mac os"
i encode it with rawurlencode and put it in the URL after ?name= in an anchor.
when i click it i see the following in the browsers url.
index.php?name=windows%20%5C%22mac%20os%5C%22
and then i get it with javascript with jquery bbq.
var string = $.deparam.querystring();
document.write(string.name);
and get:
windows \"mac os\"
i want to get windows “mac os” when i output it with javascript. and then i want to split the words to:
array[0] = windows
array[1] = mac os
the first step i think should be to get the string with rawurldecode but for javascript so i will get windows “mac os” rather than windows \”mac os\”?
and then the second step should be what regexp to use in javascript split() to split it to the words in the array above?
ive tried a numerous options but none is working. im stuck here..and its really frustrating. any help with these 2 steps would be appreciated
The first part of the question:
I tried a
rawurlencodeon the same input, and it worked fine. My guess is something is adding slashes (perhapsmagic_quotes) and you will need to remove them:So for your link:
That should encode it to look like this:
The second part of the question:
I did some searching since I am not a regex expert, and couldn’t find anything quick to help you out with splitting the string into an array in javascript, but it looks like it can be done…. probably pretty easily.