get('Matrice'); $matrici = []; if (isset($data['value']) && is_array($data['value'])) { foreach ($data['value'] as $item) { $nome = $item['NomeMatrice'] ?? ''; if ($nome !== '' && substr($nome, 0, 1) !== '*') { $matrici[] = [ 'IdMatrice' => $item['IdMatrice'], 'NomeMatrice' => $nome, 'MacroMatrice' => $item['MacroMatrice'] ?? null, ]; } } usort($matrici, fn($a, $b) => strcasecmp($a['NomeMatrice'], $b['NomeMatrice'])); } $json = json_encode(['success' => true, 'value' => $matrici]); if (!is_dir(__DIR__ . '/cache')) mkdir(__DIR__ . '/cache', 0777, true); file_put_contents($cacheFile, $json); echo $json; } catch (Exception $e) { http_response_code(500); echo json_encode(['success' => false, 'message' => $e->getMessage()]); }