I have an array like this :
array(3) {
[0]=>
array(2) {
[0]=>
string(6) "action"
[1]=>
string(5) "depot"
}
[1]=>
array(2) {
[0]=>
string(9) "Demandeur"
[1]=>
string(11) "Particulier"
}
[2]=>
array(2) {
[0]=>
string(3) "Nom"
[1]=>
string(6) "Cheval"
}
But I want an associative array, to access it like this : $_REQUEST['Nom'] and have in return 'Cheval' etc...
The first array is actually an object, created with jQuery and here is his construction :
jQuery('input:submit').click(function() {
var itemMetaArray = {};
jQuery('.frm_pro_form :input:not(:hidden, :submit)').each(function() {
if(jQuery('#field_demande').val() != undefined){
itemMetaArray['action'] = jQuery('#field_demande').val();
}
else itemMetaArray['action'] = jQuery('#field_demande2').val();
var label = jQuery(this).closest('.frm_form_field').find('.frm_primary_label').text().trim();
if(jQuery(this).attr('name').indexOf("file") == -1 ) {
itemMetaArray[label] = jQuery(this).val();
}else{
var fileName = jQuery(this).attr('name');
fileName = fileName.substring(0,fileName.length-2);
itemMetaArray[label] = fileName;
}
});
After this, I do some parsing in PHP :
$dataInfo = explode(",",$_POST['dataInfo']);
for ($i = 0; $i < count($dataInfo); ++$i){
$tmpWithoutBrackets[$i] = trim($dataInfo[$i],"{..}");
$tmpWithoutColon[$i] = explode(":",$tmpWithoutBrackets[$i]);
for($j = 0; $j < (count($tmpWithoutColon) + 1); ++$j){
$arrayFinal[$i][$j] = trim($tmpWithoutColon[$i][$j],"\"");
}
$arrayFinal[$i] = array_diff($arrayFinal[$i],array(""));
}
$arrayFinal is the same array as arrayInfo
Thanks in advance for your help