3v4l.org

run code in 300+ PHP versions simultaneously
<?php $category = array( '1' => 'Ctegory 1', '2' => 'Ctegory 2', '3' => 'Ctegory 3', ); $explodeID = explode(',', '3,1'); foreach($category as $key => $value){ if(in_array($key, $explodeID)){ echo "$key => $value" . PHP_EOL; } }
based on IfLCQ
Output for 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.28, 7.4.0 - 7.4.16, 8.0.0 - 8.0.3
1 => Ctegory 1 3 => Ctegory 3