| Server IP : 80.211.21.168 / Your IP : 216.73.217.33 Web Server : Apache System : Linux alex-webdesign.it 3.10.0-1160.119.1.el7.tuxcare.els22.x86_64 #1 SMP Mon Aug 18 06:07:12 UTC 2025 x86_64 User : admin_japan ( 10003) PHP Version : 8.2.32 Disable Function : opcache_get_status MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/vhosts/cerchijapan.it/ai4dealers.com/ |
Upload File : |
<?php
header('Content-Type: text/html; charset=utf-8');
// Legge il contenuto del file JSON
$jsonData = file_get_contents('data.json');
if ($jsonData === false) {
die("Errore nel leggere il file JSON.");
}
// Rileva l'encoding
$encoding = mb_detect_encoding($jsonData, 'UTF-8, ISO-8859-1, UNICODE, Windows-1252', true);
echo "Encoding rilevato: " . $encoding . "<br>";
// Decodifica il JSON in un array associativo
$data = json_decode($jsonData, true);
if ($data === null) {
die("Errore nella decodifica del JSON: " . json_last_error_msg());
}
// Recupera l'array dei record: se il JSON contiene una chiave 'Ads', la usa, altrimenti assume che l'intero file sia l'array
if (isset($data['Ads']) && is_array($data['Ads'])) {
$records = $data['Ads'];
} elseif (is_array($data)) {
$records = $data;
} else {
$records = [$data];
}
// Definisci l'array dei termini di ricerca
$searchTerms = [
"Pietro a Vico",
"Guamo",
"Massa",
"La Spezia",
"Massarosa",
"Chiesina Uzzanese"
];
// Imposta il limite di elementi da stampare (5 in questo caso)
$limit = 10;
$count = 0;
foreach ($records as $record) {
// Controlla se l'elemento contiene la chiave "Public" e all'interno "Location"
if (isset($record['Public']) && isset($record['Public']['Location'])) {
$location = $record['Public']['Location'];
// Scorre l'elenco dei termini cercando se uno di essi è presente nella stringa Location (case-insensitive)
foreach ($searchTerms as $term) {
if (stripos($location, $term) !== false) {
echo "<pre>" . json_encode($record, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) . "</pre><hr>";
$count++;
break; // Interrompe il ciclo interno e passa al record successivo
}
}
}
if ($count >= $limit) {
break; // Esce dal ciclo se ha già stampato 5 record
}
}
if ($count == 0) {
echo "Nessun record trovato che corrisponde ai criteri di ricerca.";
}
?>