<?php
require 'config.php';

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.paystack.co/bank",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Authorization: Bearer sk_test_5b1fc3ab64333d1171d397027c5901ed96ffd48f"
  ),
));

$response = curl_exec($curl);
$header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
        $header = substr($response, 0, $header_size);
        $body = substr($response, $header_size);

        curl_close($curl);

 //echo var_dump($response);
 $resp = json_decode($response, true);

 $datax = $resp['data'];

 //echo $datax[0]['name'];
 $i=0;

 foreach($datax as $val) {
  $name = $datax[$i]['name'];
  $bcode = $datax[$i]['code'];

echo $name;
echo '<br>';
echo $bcode;

  $sql=$con->query("INSERT INTO bank_list  (bank, bank_code) 
  VALUES ('$name', '$bcode')") or die("Error: ".mysqli_error($con));
  

  $i++;
}



 // echo var_dump($datax);




?>