php array in url from json
- by mcgrailm
Here is what I want to do:
I have some json like this
var foo = {
format:"json",
type:"test",
id:"26443"
};
and I awant to put that in a url like this
'http://example.com/a:3:{s:6:"format";s:4:"json";s:4:"type";s:5:"test";s:2:"id";s:5:"26443";}'
which I will then put into ajax call but everything I have tried results in error 501 BAD URI could someone tell me how to do this
I've tried this
function js_array_to_php_array(a) {
var a_php = "";
var total = 3;
for (var key in a){
total;
a_php = a_php + "s:" + String(key).length + ":\"" + String(key) + "\";s:" + String(a[key]).length + ":\"" + String(a[key]) + "\";";
}
a_php = "a:" + total +":{" + a_php + "}";
return a_php;
}
which I found out on the web but had to mod to get to run but still no luck