loading
main.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
function mycompact($coll)
{
    $result = [];
    foreach ($coll as $item) {
        // is_null функция (предикат) стандартной библиотеки
        if (!is_null($item)) {
            $result[] = $item;
        }
    }
    
    return $result;
}

print_r(mycompact([0, 1, false, null, true, 'wow', null]));
PHP 7.0.8 (Legacy: use the following for new features: Command-line PHP: https://repl.it/languages/php_cli PHP Web Server: https://repl.it/languages/php7