- array_map: documentation ( source)
- var_dump: documentation ( source)
- str_repeat: documentation ( source)
- array_filter: documentation ( source)
- range: documentation ( source)
- str_starts_with: documentation ( source)
<?php
$original = [];
foreach (range(1, 20_000) as $iteration) {
$original[] = [
'id' => str_repeat("{$iteration}.", 4),
'name' => 'name',
];
}
var_dump(
array_map(
static function (array $item): string {
return "{$item['id']}#{$item['name']}";
},
array_filter(
$original,
static function (array $item): bool {
return str_starts_with($item['id'], '11');
}
)
)
);
This script was stopped while abusing our resources