fork download
  1. <?php
  2. $a = [1, 2, 3, 4, 5];
  3. $purch = [
  4. ['test_col' => 'hello', 'purchased_sape_ref_id' => 1],
  5. ['test_col' => 'world', 'purchased_sape_ref_id' => 2],
  6. ['test_col' => 'stack', 'purchased_sape_ref_id' => 3]
  7. ];
  8.  
  9. $diff = array_diff($a, array_column($purch, 'purchased_sape_ref_id'));
  10.  
  11. foreach ($a as $a_value) {
  12. if (!in_array($a_value, $diff)) {
  13. echo 'This id is in the $a array: '.$a_value."\n";
  14. } else {
  15. echo 'This id is not in the $a array: '.$a_value."\n";
  16. }
  17. }
Success #stdin #stdout 0.02s 82880KB
stdin
Standard input is empty
stdout
This id is in the $a array: 1
This id is in the $a array: 2
This id is in the $a array: 3
This id is not in the $a array: 4
This id is not in the $a array: 5