title: Message: preg_match() expects parameter 2 to be a string, array given while exporting the data in CodeIgniter
body: <p>I am using CodeIgniter. I am exporting the data in the excel sheet.</p>
  
  <p>Now What I am doing is, I have <code>Payment option</code> and <code>Payment Details</code> column.</p>
  
  <p>I have to display the output in the column like</p>
  
  <pre><code>if(Payment option == 'a'){
  //display array in the column
  }
  else if(Payment option == 'b')
  {
  //display array in the column
  }
  else{
  //
  }
  </code></pre>
  
  <p><strong>Expected output</strong></p>
  
  <p><a href="https://i.stack.imgur.com/GtbTw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GtbTw.png" alt="enter image description here"></a></p>
  
  <p>I am getting the error</p>
  
  <p>1) </p>
  
  <pre><code>A PHP Error was encountered
  Severity: Notice
  Message: Undefined offset: 0
  Filename: Cell/DefaultValueBinder.php
  </code></pre>
  
  <p>2) </p>
  
  <pre><code>A PHP Error was encountered
  Severity: Warning
  Message: preg_match() expects parameter 2 to be string, array given
  Filename: Cell/DefaultValueBinder.php
  </code></pre>
  
  <p><strong>Export code</strong></p>
  
  <pre><code>public function export_order_list(){
    $object = new PHPExcel();
    $object-&gt;setActiveSheetIndex(0);
    $table_columns = array("Customer Name","Email","Mobile no","Alternet no","Payment option","Payment Details","Date of created");
    $column = 0;
    $object-&gt;getActiveSheet()-&gt;getStyle('1:1')-&gt;getFont()-&gt;setBold(true);
  
    foreach($table_columns as $field)
    {
     $object-&gt;getActiveSheet()-&gt;setCellValueByColumnAndRow($column, 1, $field);
  
     $column++;
    }
    $export_list = $this-&gt;Customer_model-&gt;export_order_list_model();//getting all data
    $excel_row = 2;
    foreach($export_list as $row)
    {
     $cust_name=$row-&gt;c_firstname." " .$row-&gt;c_middlename."".$row-&gt;c_lastname;
     if ($row-&gt;payment_option=='A') {
           $payment_details=array(
            'Account holder name:' =&gt; $row-&gt;account_holder_name,
            'Account no:'=&gt;$row-&gt;e_account_no,
            'Cheque no:'=&gt;$row-&gt;cheque_no
           );
  
     }
     if ($row-&gt;payment_option=='b') {
        $payment_details=array(
          'Name On Card:' =&gt; $row-&gt;c_name_on_card,
          'Card Number:'=&gt;$row-&gt;c_card_number,
         'Exp month'=&gt;$row-&gt;c_exp_month,
         );
     }
     else{
       $payment_details="";
     }
  
     $object-&gt;getActiveSheet()-&gt;setCellValueByColumnAndRow(0, $excel_row, $cust_name);
     $object-&gt;getActiveSheet()-&gt;setCellValueByColumnAndRow(1, $excel_row, $row-&gt;c_email_id);
     $object-&gt;getActiveSheet()-&gt;setCellValueByColumnAndRow(2, $excel_row, $row-&gt;c_mobileno);
     $object-&gt;getActiveSheet()-&gt;setCellValueByColumnAndRow(3, $excel_row, $row-&gt;c_alternetno);
     $object-&gt;getActiveSheet()-&gt;setCellValueByColumnAndRow(4, $excel_row, $row-&gt;payment_option);
     $object-&gt;getActiveSheet()-&gt;setCellValueByColumnAndRow(5, $excel_row, $payment_details);
     $object-&gt;getActiveSheet()-&gt;setCellValueByColumnAndRow(6, $excel_row, $row-&gt;c_date_of_added);
     $excel_row++;
    }
  
    $object_writer = PHPExcel_IOFactory::createWriter($object, 'Excel5');
          header('Content-Type: application/vnd.ms-excel');
          header('Content-Disposition: attachment;filename="Order list.xls"');
          $object_writer-&gt;save('php://output');
   }
  </code></pre>