I write test code, that post array on php page. Php page need write this array to file to check data.
JQuery:
$("#Trash").click(function () {
$.post("tests.php",
{'ids[]': ArrayCheckBox},
function(result){
window.location = 'tests.php';
}
);
});
In tests.php i tried to parse:
$s = array();
foreach ($_POST as $k => $v) {
if (is_array($v)) {
if ($v=='ids[]')
array_push($s, $v[0]);
}
}
$file = $_SERVER['DOCUMENT_ROOT'] .'/test2.txt';
$current = file_get_contents($file);
$current .= implode(', ', $s);
file_put_contents($file, $current);
But this code write only "1" every time. How fixed it?