0
How to individually access string values cores
and array filmes
on a PHP page?
var filmes = ["Mad Max", "Assassin's Creed"];
var cores = "cor_um=Azul&cor_dois=Preto";
$.post("autosave.php", {'_cores': cores, '_filmes': filmes});
0
How to individually access string values cores
and array filmes
on a PHP page?
var filmes = ["Mad Max", "Assassin's Creed"];
var cores = "cor_um=Azul&cor_dois=Preto";
$.post("autosave.php", {'_cores': cores, '_filmes': filmes});
1
Using the tag $_POST
$filmes = $_POST['_filmes'];
parse_str($_POST['cores'], $cores);
To get each value of the sent arrays, just use the foreach
foreach($filmes as $filme) {
print_r($filme)
}
I recommend you change the format of your variable colors to an array instead of query string
Browser other questions tagged php jquery
You are not signed in. Login or sign up in order to post.
Jeferson, how do I take each value individually?
– lucasbento
As you are passing them in an array, you need to traverse this array using
foreach
, I’ll edit with an example– Jeferson Assis
If you send colors as an array, just do the same thing for the variable
$cores
– Jeferson Assis
"cores"
is astring
is serialized from a form. This is just a MCV example.– lucasbento
Add an option for you to transform query string into array
– Jeferson Assis
Jeferson, if you can supplement your answer by showing how you do...
– lucasbento