0

我有一个这样的数组:

Array (
  [0] => Mollie_Response Object (
     [@attributes] => Array ( [version] => v1 ) 
     [success] => true 
     [resultcode] => 10 
     [resultmessage] => Customer has the following payment methodes. 
     [services] => Mollie_Response Object ( 
        [ivr] => true 
        [minitix] => true 
        [psms] => true 
        [ideal] => true 
        [paysafecard] => false
     )
   )
 )

我想获得 [ideal] 的价值,但我不知道该怎么做。

我试过的是这样的:

$response = $simplexml;

foreach( $response as $value ) 
{
    echo 'Test: '.$value[0].'<br>';
}

回应是这样的:

Test: true
Test: 10
Test: Customer has the following payment methodes.
Test: 

有什么建议么?

4

2 回答 2

5

那将是这样的:

$variable[0]->services->ideal
于 2013-02-26T16:40:19.747 回答
1

我认为识别有助于检查字段:

Array ( [0] => 
  Mollie_Response Object ( 
      [@attributes] => Array ( [version] => v1 ) 
      [success] => true 
      [resultcode] => 10 
      [resultmessage] => Customer has the following payment methodes. 
      [services] => Mollie_Response Object ( 
          [ivr] => true 
          [minitix] => true 
          [psms] => true 
          [ideal] => true 
          [paysafecard] => false 
      )
  )
)

所以现在很明显你需要使用$response[0]->services->ideal.

于 2013-02-26T16:43:02.330 回答