<?php $p=[]; if(isset($_POST['data'])){ $p=$_POST; } $msg=json_encode($p); ?><!doctype html> <html> <body> <?=$msg?> <pre><?=print_r($p, true)?></pre> <form method="post"> <input type="number" name="id" value=1 > <input type="number" name="data[0][id]" value=1 > <input type="text" name="data[0][data]" value="abc" > <input type="number" name="data[1][id]" value=2 > <input type="text" name="data[1][data]" value="xyz" > <button>save</button> </form> </body> </html>