Advertisement
kura2yamato

perbaikan 69

Aug 7th, 2018
350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3.     class Model_mahasiswa extends CI_Model {
  4.    
  5.    
  6.     Function getdata ()(
  7.    
  8.    
  9.     $url = "http://10.11.4.34/mahasiswa/index_get?nama="._GET["nama"];
  10.    
  11.             $ch = curl_init();
  12.  
  13.             curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
  14.            
  15.             curl_setopt($ch,CURLOPT_URL,$url);
  16.  
  17.             $result=curl_exec($ch);
  18.  
  19.             curl_close($ch);
  20.            
  21.             var_dump(json_decode($result,true)); ---------> buat decode datanya
  22.            
  23.            
  24.             $key = $result;
  25. //---> buat tammpung hasil bener ga ?
  26. //salah.. $result masih bentuk json aka string.. harus di json_decode dulu
  27.             $key = json_decode($result,TRUE);
  28.            
  29.             Foreach($key as $hasil => $value) {  
  30. //----------> buat looping , tapi masih invalid foreach
  31. //bukan invalid.. $key tidak kebaca sebagai array/object. perhatikan penjelasan errornya
  32.            
  33.                 $ret[$h] = trim($value);
  34.                     }
  35.     )
  36.     }
  37. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement