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] => [email protected]
            [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.

1
  • 4
    Just follow the indentation to see the hierarchy echo $response['return']['custom']; Commented Nov 29, 2017 at 18:46

2 Answers 2

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']

Sign up to request clarification or add additional context in comments.

Comments

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.