title: PHP check the exist of data in array and prevent from adding data
body: <p>I want to add array to an array of array. Then do checking on the existence of previous added array . Here is how I do the checking.</p>
  
  <pre><code>for ($x = 0; $x &lt;= 10; $x++){
    $data = array(
          'order_id' =&gt; $invoice-&gt;order_id,            
        );
  
    $datas = array(); 
    // this is the array contains array I create to 
    // let me check whether $data exist in it.
  
    foreach ($datas as $value){
  
    if ($value['order_id']==$data['order_id']){ 
        //if the $data already exist in $datas  
        print "ok";
    }    
  
    $datas = array_push($datas,$data); 
    // push $data to $datas for the next checking of existing of $data, 
    // that means, next time if same order id exist, it will be found in 
    // the above checking. 
  }
  </code></pre>
  
  <p>However, the code seems not working, what's the proper way to do this? </p>
  
  <p>The error message:</p>
  
  <pre><code>Invalid argument supplied for foreach()
  array_push() expects parameter 1 to be array, null given 
  </code></pre>