Answer the question
In order to leave comments, you need to log in
How to find out if there was such an array?
I welcome everyone!
There is this JSON
{
"ok":true,
"result":[
{
"var2":"fiudckj",
"var215":"5",
"received":{
"from":"USERNAME1",
"AMOUNT":10000,
"message":"Subscribe to pewdiepie"
},
"sent":[
]
},
{
"var2":"rhdjrvjkf",
"var215":"562",
"received":{
"from":"USERNAME2",
"AMOUNT":10000,
"message":"Subscribe to pewdiepie"
},
"sent":[
]
},
],
"previous_transaction":{
"var2":9610895000003,
"var215":"101"
}
}
Answer the question
In order to leave comments, you need to log in
1) enumeration of array elements with comparison:
foreach ($json['result'] as $_item) {
if ($_item['received']['from'] == 'USERNAME1' and $_item['received']['AMOUNT'] == '12345678')
if ( preg_match('|"from":"USERNAME1",\s"AMOUNT":12345678,|is', $json, $match) )
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question