$idArray = array(1,2,3,4);
can I write this line in HTML?
In the particular case you mentioned, I would implode the array to a string and then explode it when you post the form.
$str = rawurlencode(implode(",",$idArray));
and then on the post processing:
$idArray = explode(",",rawurldecode($_POST['arr']));