Answer the question
In order to leave comments, you need to log in
How to access key in JSON array?
Sorry for stupidity. I can't get the "event" value using php.
$array['event'] doesn't work.
$array[0]['event'] doesn't work.
How right?
$array = array(1) {
["{
__"type":_"notification",
__"event":_"payment_waiting_for_capture",
__"object":_{
____"id":_"22d6d597-000f-5000-9000-145f6df21d6f",
____"status":_"waiting_for_capture",
____"paid":_true,
____"amount":_{
______"value":_"2_00",
______"currency":_"RUB"
____},
____"authorization_details":_{
______"rrn":_"10000000000",
______"auth_code":_"000000"
____},
____"created_at":_"2018-07-10T14:27:54_691Z",
____"description":_"Заказ_№72",
____"expires_at":_"2018-07-17T14:28:32_484Z",
____"metadata":_{},
____"payment_method":_{
______"type":_"bank_card",
______"id":_"22d6d597-000f-5000-9000-145f6df21d6f",
______"saved":_false,
______"card":_{
________"first6":_"555555",
________"last4":_"4444",
________"expiry_month":_"07",
________"expiry_year":_"2021",
________"card_type":_"MasterCard",
______"issuer_country":_"RU",
______"issuer_name":_"Sberbank"
______},
______"title":_"Bank_card_*4444"
____},
____"refundable":_false,
____"test":_false
__}
}"]=>
string(0) ""
}
Answer the question
In order to leave comments, you need to log in
If according to the initial data from the question, then so
<?php
$array = $_POST;
$json_str = array_key_first($array);
$json = json_decode($json_str, true);
var_dump($json['event']);
<?php
$json_data = file_get_contents('php://input');
$json = json_decode($json_data, true);
var_dump($json['event']);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question