Skip to content

Instantly share code, notes, and snippets.

@rombyar
Created September 17, 2020 02:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rombyar/4a6efbeab91879d049ecf0e66382a6fd to your computer and use it in GitHub Desktop.
Save rombyar/4a6efbeab91879d049ecf0e66382a6fd to your computer and use it in GitHub Desktop.
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Update_rate extends CI_Controller
{
public function index(){
$content = file_get_contents("https://api.exchangeratesapi.io/latest?base=USD");
$result=json_decode($content, true);
$array_payment = ['paypal', 'perfectmoney', 'webmoney'];
foreach($array_payment as $output) {
$rate_bulat = round($result['rates']['IDR']);
$this->payment_model($output, $rate_bulat);
}
}
public function payment_model($payment, $rate)
{
$data = array ('rate' => $rate);
$this->db->where('key', $payment);
$this->db->update('payments', $data);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment