- var_dump: documentation ( source)
- array_filter: documentation ( source)
<?php
$nr = 2;
$nr_copy = 2;
$a = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
$nr = 3; // you can freely modify $nr because the function below is using $nr_copy
$a = array_filter($a, create_function('$e', '
global $nr_copy;
return $e % $nr_copy == 0;
'));
var_dump($a);