On 24.03.2026 11:08, 沉默领域、 wrote:
// Current
$names = array_values(array_filter($users, fn($u) => $u->active));
$first = count($names) > 0 ? $names[0] : null;
Not the best example, as you can also do:
$first = array_find($users, fn ($user) => $user->active)?->name;
There are some existing functions like array_column() and array_first()
that seems you didn't know existed. So, there's been some progress in
this territory too.
--
Aleksander Machniak
Kolab Groupware Developer [https://kolab.org]
Roundcube Webmail Developer [https://roundcube.net]
----------------------------------------------------
PGP: 19359DC1 # Blog: https://kolabian.wordpress.com