Pass an array from an HTML form using Hidden field

It is simple way to pass your array using hidden field of form and get to another side  where you want to use this array's value


Snippet

Create Array

$arrNodeIds = array();
foreach ($data as $k => $objNode) {
$arrNodeIds[] = $objNode->nid;
}

Assign array to hideen field of form
<form method="post" action="/ess_upload/save_images">
<input type="hidden" name="hdnArrNodeIds" value="">
</form>

Get value from other side

$arrNodeIds = unserialize(urldecode($_POST["hdnArrNodeIds"]));
foreach($arrNodeIds as $intNodeId){
    echo $intNodeId;
}

No comments: