Fresh code drop

Get the First and Last Array Values

JAVASCRIPT

PHP 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';

Turn your code into a post.Five templates are free—no account needed.

Remix this snap