I have been trying to make an array out of the values from a POST array
its very interesting - I am nearly there ...
My $_POST includes these variables:
$POST["x_new_stat"]
$POST["x_new_loc"]
$_POST["x_feat"]
I want an array with variables like this:
$Some_array["N_new_stat"]
$Some_array["N_new_loc"]
$Some_array["N_feat"]
So this is what I've done so far !
foreach($POST as $field=>$value){
if(substr($field,1,1)== ""){
$new = "\$N".substr($field,1,15);
$long_string = $long_string.",".$new;
} // end if
} // end loop
$long_string = substr($long_string,1,256);
$New_array = explode(",",$long_string);
$Good_array = "array=(";
foreach($New_array as $field=>$value)
{
$Good_array = $Good_array.$value."=>"."'a'".",";
} // end loop
$Some_array = $Good_array.");";
echo "$Some_array";
exit();
The result of the above is to have a string that is very nearly a php command
to creat the array, I just need to get rid of the last comma at the eand of the list before the )
I would replace the "a"'s with real vars later.
Thing is when I get rid of the comma how would I make this command-in-a-string execute ?
Well I am probably going all over the shop just to do something easy ???
Any ideas ?