title: how to cek array php
body: <p>I have an array that I will insert into the item table, here I use multiple inserts</p>
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [id_service] =&gt; 2
              [tracking_number] =&gt; RJC219384044389234035
          )
  
      [1] =&gt; Array
          (
              [id_service] =&gt; 1
              [tracking_number] =&gt; RJC749944771469498146
          )
  )
  </code></pre>
  <p>in the item table, there is already id_service: 2
  how to make validation, when one of the input is already in the item table, then all the input is false so it fails?</p>
  <p>my code</p>
  <pre><code>public function nyobain()
    {
      $resi             = $this-&gt;input-&gt;post('kode'); //tracking_number
      $expld            = explode(' ', $resi);
      $data             = $this-&gt;M_outbound_destinasi-&gt;dbGet($expld); //get 'id_service' where tracking_number
  
      // $db  = $this-&gt;db-&gt;query(&quot;SELECT id_service FROM `tabel_items`&quot;)-&gt;result();
      // foreach ($db $key) {
      //     $temp=array($key-&gt;id_service);
      // }
      // how to cek ? if id_service already in the item table
  
      foreach ($data as $key) {
      $idnya                = $key['id_service'];
      $id_outbound          = $key['id_outbound'];
      $id_indes             = $key['id_indes'];
      $id_outbag            = $key['id_outbag'];
  
      $data_insert = array(
        'jenis'           =&gt; 'outbound-destinasi',
        'id_service'      =&gt; $idnya,
        'id_indes'        =&gt; $id_indes,
        'id_outbound'     =&gt; $id_outbound,
        'id_outbag'       =&gt; $id_outbag,
        'id_admin'        =&gt; $this-&gt;session-&gt;userdata('ses_id')
      );
      $this-&gt;db-&gt;insert('tabel_items', $data_insert);
    }
    echo json_encode($data);
    }
  </code></pre>