<?php
$currencies = [
(object) ['name' => 'algo', 'fullName' => 'Algorand'],
(object) ['name' => 'ardr', 'fullName' => 'Ardor'],
(object) ['name' => 'eth', 'fullName' => 'Eth']
];
$filter = ["eth", "algo"];
var_export(
array_filter(
$currencies,
fn($obj) => in_array($obj->name, $filter)
)
);
- Output for 7.4.33, 8.0.1 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
- array (
0 =>
(object) array(
'name' => 'algo',
'fullName' => 'Algorand',
),
2 =>
(object) array(
'name' => 'eth',
'fullName' => 'Eth',
),
)
- Output for 7.2.34
- Parse error: syntax error, unexpected '=>' (T_DOUBLE_ARROW), expecting ',' or ')' in /in/BJcSX on line 14
Process exited with code 255.
preferences:
96.49 ms | 407 KiB | 5 Q