<?php
$selected = $_POST['regulators'] ?? [];

$brokers = [
  [
    "name" => "Trade Nation",
    "regulators" => ["Australia Securities & Investment Commission"],
    "score" => "8.99"
  ],
  [
    "name" => "GO MARKETS",
    "regulators" => ["ASIC Master Maker (MM)"],
    "score" => "8.98"
  ],
  [
    "name" => "MultiBank Group",
    "regulators" => ["Cyprus Securities and Exchange Commission"],
    "score" => "8.96"
  ],
  // Add the rest of your broker data here...
];

$filtered = array_filter($brokers, function($broker) use ($selected) {
  foreach ($selected as $reg) {
    if (in_array($reg, $broker['regulators'])) {
      return true;
    }
  }
  return empty($selected); // If nothing selected, show all
});

foreach ($filtered as $b) {
  echo "<div class='broker-card'>";
  echo "<strong>{$b['name']}</strong><br>";
  echo "Regulators: " . implode(', ', $b['regulators']) . "<br>";
  echo "Score: {$b['score']}";
  echo "</div><hr>";
}
?>
