0

从我的 SOAP 服务中,我如何更改从这个肥皂服务中获得的数据:

Array
(
    [NE] => 42616324457
    [EMAIL] => bertho_joris@yahoo.co.id
    [TIPE] => POSTPAID
    [NAMA] => ALBERTHO
    [TELP] => 0812345678
    [DN] => 127272748174
    [STATUS_LOGIN] => 1
    [DESC_LOGIN] => Valid
)

成为这样的形式:

Array
(
     [0] => stdClass Object
         (
            [id] => 1
            [NE] => 42616324457
            [EMAIL] => bertho_joris@yahoo.co.id
            [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)));
?>

请帮我更改数组的格式

4

2 回答 2

1

只需转换为对象:

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

结果:

Array (
    [0] => stdClass Object (
         [A] => 0
         [B] => 1
     )
)
于 2012-11-27T10:17:44.833 回答
0

创建一个标准类

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

$object = new stdClass();
foreach($data as $key => $value) {
    $object->$key = $value;
}
print_r($object);
于 2012-11-27T10:14:47.743 回答