I have two arrays and I post the arrays in one input;
<input name='sistem[]' type='hidden' value='$items[$count]|$staff[$z]' />
// $count and $z are index
After post, how do I extract them into two separate arrays again?
Like this?
$items=new Array();
$staff=new Array();
foreach($_POST['sistem'] as $item){
$itemSplit=explode('|',$item);
$items[]=$itemSplit[0];
$staff[]=$itemSplit[1];
}
I'm not sure its the best solution, but one solution could be to prefix your values
Two things: If it's actually just a hidden input field, why don't you make it into two fields in your code? Or, even better, store it in the session so that there is no chance a malevolent user can't change the value on the field on submitting the request to the web server?
But to answer the question directly:
$parts = explode('|', $_REQUEST['sistem'][0]);
foreach ($_POST['sistem'] as $key => $value)
{
$tmp = explode("|", $value);
$items[$key] = $tmp[0];
$staff[$key] = $tmp[1];
}