1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| <?php
$url = 'https://www.yaesu.com/jp/en/wires-x/id/id_eu.php';
$contents = file_get_contents($url);
preg_match_all(
<<<REGEXP
/
dataList\[\d+]\ =\ {
id:"(?P<id>\d+)",
\ room_id:"(?P<room_id>\d+)",
\ call_sign:"(?P<call_sign>\w+)",
\ city:"(?P<city>[^"]+)",
\ state:"(?P<state>[^"]+)",
\ country:"(?P<country>[^"]+)"
};
/x
REGEXP,
$contents,
$matches,
PREG_SET_ORDER
);
// Nettoyage et création du tableau associatif
$data = array_map(fn ($m) => [
'id' => $m['id'],
'room_id' => $m['room_id'],
'call_sign' => $m['call_sign'],
'city' => $m['city'],
'state' => $m['state'],
'country' => $m['country'],
], $matches);
// Filtrage
$keep = ['F1TRN', 'F5SHD']; // Tableau de call_signs à conserver
$filter = fn ($e) => in_array($e['call_sign'], $keep); // Closure de filtrage
$data = array_filter($data, $filter); // Filtrage
print_r($data); // Résultat final |
Partager