HTML PHP
(quick examples)
APPEND NAME[] <form method="post"> <input type="text" name="colors[]"> <input type="text" name="colors[]"> <input type="submit" value="GO"> </form>
$_POST["COLORS"] IS AN ARRAY print_r($_POST["colors"]);
APPEND NAME[KEY][] <form method="post"> <input type="text" name="fav[c][]"> <input type="text" name="fav[c][]"> <input type="text" name="fav[f][]"> <input type="text" name="fav[f][]"> <input type="submit" value="GO"> </form>
$_POST["FAV"] IS A NESTED ARRAY print_r($_POST["fav"]); print_r($_POST["fav"]["c"]); print_r($_POST["fav"]["f"]);
<form id="form" onsubmit="return ajax()"> <input type="text" name="fav[c][]"> <input type="text" name="fav[c][]"> <input type="text" name="fav[f][]"> <input type="text" name="fav[f][]"> <input type="submit" value="GO"> </form>
function ajax () { GET FORM DATA var data = new FormData(document .getElementById("form")); AJAX SEND fetch("SCRIPT.PHP", { method:"POST", body:data }) .then(res => res.text()) .then(res => console.log(res)); return false; }