在将值传递给
前额
您需要确保值的类型是
数组
if(is_array($value)){
foreach($value as $key => $val){
// Your code
}
}else{
// Do nothing
}
要插入,可以使用此代码
public function insert_pay_slip_data($data,$com_name){
$con = $this->__construct();
$shareArray = array();
foreach($data as $key=>$value){
$valueArray = explode(",",$value);
foreach($valueArray as $index=>$path){
$sql = "INSERT INTO `pay_slips`(`paye_id`, `trade_id`, `inv_pdf`, `created_date`, `created_by`) VALUES (LAST_INSERT_ID(), '".$com_name."','".$path."',NOW(),'".$_SESSION['email']."')";
$response = mysqli_query($con, $sql);
if(!$response){
// Insertion Failed
}
}
}
}