3v4l.org

run code in 300+ PHP versions simultaneously
<?php $st_array = array(); $st_data1['id'] = 1; $st_data1['title'] = 'Jane doe'; $st_data1['disk'] = '1,3,2'; array_push($st_array, $st_data1); $rc_disk_id = '1,3'; $st_data2['id'] = 2; $st_data2['title'] = 'Jane Smith'; $st_data2['disk'] = '3,1,4'; array_push($st_array, $st_data2); foreach($st_array as $st_data) { $rc_disk_ids = explode(",",$rc_disk_id); $st_disk_ids = explode(',', $st_data['disk']); $match = array_diff($rc_disk_ids, $st_disk_ids); if (empty($match)) { echo "\nFound\n"; print_r($st_data); } else { echo "Nope!"; } }
Output for 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.31, 8.2.0 - 8.2.26, 8.3.0 - 8.3.14, 8.4.1
Found Array ( [id] => 1 [title] => Jane doe [disk] => 1,3,2 ) Found Array ( [id] => 2 [title] => Jane Smith [disk] => 3,1,4 )

preferences:
83.24 ms | 407 KiB | 5 Q