Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Model_mahasiswa extends CI_Model {
- Function getdata ()(
- $url = "http://10.11.4.34/mahasiswa/index_get?nama="._GET["nama"];
- $ch = curl_init();
- curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
- curl_setopt($ch,CURLOPT_URL,$url);
- $result=curl_exec($ch);
- curl_close($ch);
- var_dump(json_decode($result,true)); ---------> buat decode datanya
- $key = $result;
- //---> buat tammpung hasil bener ga ?
- //salah.. $result masih bentuk json aka string.. harus di json_decode dulu
- $key = json_decode($result,TRUE);
- Foreach($key as $hasil => $value) {
- //----------> buat looping , tapi masih invalid foreach
- //bukan invalid.. $key tidak kebaca sebagai array/object. perhatikan penjelasan errornya
- $ret[$h] = trim($value);
- }
- )
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement