PHP Dev
damienseguy's profile
Damien seguy@damienseguy•Jul 03, 2025
19.8K
Exakat's profile
Post cover image

Native array_first() and array_last() Functions in PHP 8.5

Avatar of lnLaravel News•From laravel-news.com•Jul 02, 2025•5m read time

PHP 8.5 introduces native array_first() and array_last() functions to retrieve the first and last elements from arrays. These functions address long-standing challenges with existing solutions like reset() and end() that modify array iterators or require cumbersome workarounds. The functions return null for empty arrays and work with any array structure regardless of key types. Popular frameworks like Laravel and Symfony already provide similar functionality through helper methods and polyfills.

1 Comment

Sort:

damienseguy's user avatar
Damien seguy
@damienseguy
Joined Oct 25. 2023
19.8K
Exakat's profile

Exakat

Verified

PHP developer passionate about deep language knowledge, testing, static analysis, and sustainable it

Would you recommend this post?

Copy link
WhatsApp
Facebook
X
New Squad
  • © 2026 Daily Dev Ltd.
  • Guidelines
  • Explore
  • Tags
  • Sources
  • Squads
  • Leaderboard