Skip to content
CodeWiki
Practice
Paths
Tracks
Cheatsheets
Playground
Glossary
AI era
Search
⌘K
English
English
Chinese
Practice
Paths
Tracks
Cheatsheets
Playground
Glossary
AI era
English
English
Chinese
Practice
/
Predict the output
/
PHP
/
Array functions
What does this program print?
from Array functions
PHP 8.3.33
beginner
2 min
What does this program print?
php
Copy
<?
php
$values
=
[
0
,
'0'
,
''
,
null
,
7
];
echo
json_encode
(
array_filter
(
$values
)),
PHP_EOL
;
[7]
{"4":7}
[0,"0",7]
It throws because no callback was supplied.
Check
Copy code
Open in playground
Ask AI about this kata
Report an error
previous kata
When does array_map preserve the input array keys?
Quiz
next kata
What is the first accumulator passed by array_reduce($values, $callback) when the initial…
Quiz
A new version is available
Reload