Sunday, August 8, 2021

Array function PHP convert to JSON

     public function getPackageInternet($data)
    {
        $isp = $this->model->getISPbyEmail($data['email']);
        $internet = $this->model->getAllPackageInternetByIspID($isp->id);
        $result = array();
        foreach ($internet as $paket) {
            $set['id'] = $paket->id;
            $set['paketName'] = $paket->package_name;
            $set['bandwith'] = $paket->bandwith;
            $set['price'] = $paket->price;
            array_push($result, $set);
        }
        return $result;
    }
    
    .....
    
    echo json_encode($result);

No comments:

Post a Comment