Interview question
What are the most commonly used array functions in PHP? PHP में सबसे ज़्यादा इस्तेमाल होने वाले array functions कौन से हैं?
Answer
PHP has over 80 built-in array functions. These are the ones that come up most in day-to-day code and interviews.
| Function | Purpose |
|---|---|
| count() | Number of elements in an array |
| array_push() / array_pop() | Add / remove from the end |
| array_shift() / array_unshift() | Remove / add from the beginning |
| array_slice() | Extract a portion of an array |
| array_splice() | Remove/replace a portion, modifies original array |
| array_keys() / array_values() | Get all keys / all values |
| array_reverse() | Reverse element order |
| array_flip() | Swap keys and values |
Interview tip: Know the difference between array_slice() (returns a new array, non-destructive) and array_splice() (modifies the original array in place) - a frequent follow-up.
PHP में 80 से ज़्यादा built-in array functions हैं। ये सबसे ज़्यादा daily code और इंटरव्यू में आते हैं।
| Function | उद्देश्य |
|---|---|
| count() | array में elements की संख्या |
| array_push() / array_pop() | अंत से जोड़ना / हटाना |
| array_shift() / array_unshift() | शुरुआत से हटाना / जोड़ना |
| array_slice() | array का एक हिस्सा निकालना |
| array_splice() | हिस्सा हटाना/बदलना, original array modify करता है |
| array_keys() / array_values() | सभी keys / सभी values पाना |
| array_reverse() | elements का क्रम उल्टा करना |
| array_flip() | keys और values को स्वैप करना |
इंटरव्यू टिप: array_slice() (नया array रिटर्न करता है, non-destructive) और array_splice() (original array in place modify करता है) का अंतर जानें - एक आम follow-up।
Was this answer clear?