Dinesh Uprety
@dineshuprety ·
Public
Get the First and Last Array Values
JAVASCRIPTPHP 8.5 adds native functions that return null for empty arrays.
JAVASCRIPT
CodeSnap // free canvas
Get the First and Last Array Values
<?php
$firstUser = array_first($users);
$lastUser = array_last($users);
$firstUser ??= 'No users found';