0

I have an array:

print_r($response);

will show:

    Response: Array
(
    [errors] => false
    [return] => Array
        (
            [price_recurring] => 0
            [country_code] => NL
            [invoicemethod] => instant
            [product_id] => 0
            [affiliate] => 
            [number_of_periods] => 1
           [description] => Betaling voor eventid 274
            [period_duration] => 1 month
            [date] => 29/11/2017 19:42
            [order_quantity] => 1
            [vat] => 21
            [amount_total] => 4599
            [total_paused_days] => 0
            [custom] => WEB1511980957x194237
            [emailaddress] => ik@ik.nl
            [amount_affiliate_initial] => 0
            [total] => 45,99 
            [current_status] => completed
            [amount_affiliate_recurring] => 0
            [amount_total_affiliate] => 0
            [id] => 1790226
            [price_initial] => 4599
            [current_number_of_periods] => 1
            [firstname] => 
        )

)

How can i extract the value 'custom'?

I've tried:

$response = array_shift($response); 
echo $response['custom'];  

but it will show nothing. What am i doing wrong here? I know i am close.

2 Answers2

0

you have an array inside an array

$response["return"]["custom"]

also try to var_dump (or print_r depends on what you prefer) instead of echoing when you try to navigate

var_dump( $response["custom"]);

would tell you a lot more than echoing null, which prints nothing

Elentriel
  • 1,237
  • 8
  • 21
0

$response is an array with two keys errors and return. $response['return'] in turn, is an array with several keys, including custom. Therefore, to access custom, you need to reference $response['return']['custom']

kchason
  • 2,836
  • 19
  • 25