🐘 PHP Beginner

What are PHP array functions?

Why Interviewers Ask This

This is a classic screening question for PHP roles. Hiring managers ask it early in interviews to gauge your baseline understanding and determine if you can communicate technical concepts clearly.

Answer

PHP has an extensive set of built-in array functions. Essential ones: count($arr) (number of elements), array_push($arr, $val) / array_pop($arr) (add/remove from end), array_shift($arr) / array_unshift($arr, $val) (remove/add at start), in_array($val, $arr) (check if value exists), array_key_exists($key, $arr) (check if key exists), array_merge($a, $b) (merge arrays), array_slice($arr, $offset, $length) (extract portion), array_search($val, $arr) (returns key of value), sort() / rsort() / asort() / ksort() (sorting), array_unique($arr) (remove duplicates), array_flip($arr) (swap keys and values), and array_map() / array_filter() / array_reduce() (functional operations).

Common Mistake

Candidates often give textbook answers here. Interviewers are more impressed when you relate the concept to a specific problem you solved in a real PHP project.