2012-11-27 94 views
0

從我的SOAP服務,如何更改我從這個SOAP服務獲得了數據:更改陣列格式

Array 
(
    [NE] => 42616324457 
    [EMAIL] => [email protected] 
    [TIPE] => POSTPAID 
    [NAMA] => ALBERTHO 
    [TELP] => 0812345678 
    [DN] => 127272748174 
    [STATUS_LOGIN] => 1 
    [DESC_LOGIN] => Valid 
) 

作爲這樣一種形式:

Array 
(
    [0] => stdClass Object 
     (
      [id] => 1 
      [NE] => 42616324457 
      [EMAIL] => [email protected] 
      [TIPE] => POSTPAID 
      [NAMA] => ALBERTHO 
      [TELP] => 0812345678 
      [DN] => 127272748174 
      [STATUS_LOGIN] => 1 
      [DESC_LOGIN] => Valid 
      [PASSWORD] => malaquena 
     ) 

) 

我SOAP服務代碼:

<?php 
require_once('lib/nusoap.php'); 

$Email  = $_GET['email']; 
$Password = $_GET['pass']; 

$client = new nusoap_client('http://vcare.telkomvision.net.id/services/VcareServices.php'); 
$BacaSOAP = $client->call('validateLogin', array('EMAIL' => $Email, 'PASSWORD' => md5($Password))); 
?> 

請幫我改變陣列的格式

+0

http://stackoverflow.com/questions/1869091/convert-array-to- object-php這個怎麼樣? –

回答

1

只投反對:

$array = array('A' => 0, 'B' => 1); 
$array = array((object)$array); 
print_r($array); 

結果:

Array (
    [0] => stdClass Object (
     [A] => 0 
     [B] => 1 
    ) 
) 
0

創建一個stdClass的

$data = array(
    'ne' => 1231232, 
    'email' => 'asdasdsda' 
); 

$object = new stdClass(); 
foreach($data as $key => $value) { 
    $object->$key = $value; 
} 
print_r($object); 
+0

如果我使用您的代碼,我會得到一個結果:http://pastebin.com/LsU3R0Be –