I want to use foreach in my following code only one time.and i need to paas two array value that is store_data and store_control_text to my database respective fields.Need suggestions for not using foreach loop for multiple array values..
$data = $_REQUEST['columns_one'];
$controlText = $_REQUEST['controlText'];
$store_control_text = explode(",",$controlText);
$store_data = explode(",",$data);
$query = "INSERT INTO formdetailstemp(FormId,ControlType,ControlText,ControlPara1,Mandatory) VALUES ";
$values = array(); //store all the new rows
foreach($store_data as $key =>$value){
$values[] = "('','".$value."','".$controlText."','".$controlPara."','".$mandatoryValue."')";
}
You can use
array_mapSee Simple Example