<?php


namespace Heanup\App\Api\Controller;


use Heanup\App\Api\Config\Code;
use Heanup\App\Api\Controller;
use Heanup\App\Api\Package\Database\Num;
use Heanup\Library\Sms\ReceiveSmsCc;

class Test extends Controller
{
    protected function main()
    {
        $lib = new ReceiveSmsCc();
        $data = $lib->getCountry();
        $config=Code::getData();
        $result=[];
        foreach ($data as &$item) {
            $pic_name = substr($item['img'], strrpos($item['img'], "/") + 1);
            if (!file_exists(APP_DIR . '/public/api/flag/' . $pic_name)){
                file_put_contents(APP_DIR . '/public/api/flag/' . $pic_name, file_get_contents($item['img']));
            }
            $item['img']="/flag/".$pic_name;
            $result[$item['country']]=$config[$item['country']];
            $result[$item['country']]['flag']=$item['img'];
//            $this->showSuccess($nums);
        }
//        $this->showSuccess($config);
//        $this->showSuccess($result);
        echo var_export($result);
    }

}