I am trying to filter it using array_filter
$time = (time() -10);
$data = json_decode($json, TRUE);
$datafilter = array_filter($data, function($obj)
{
return $obj->response->trade_offers_received->time_created > $time;
});
echo $datafilter;
I am getting this notice: Trying to get property of non-object. So am doing something wrong. How can i filter this array to get only object where time_created > $time ?
This is my JSON data
Array
(
[response] => Array
(
[trade_offers_received] => Array
(
[0] => Array
(
[tradeofferid] => 988832058
[accountid_other] => 212629269
[message] =>
[expiration_time] => 1455467839
[trade_offer_state] => 2
[items_to_give] => Array
(
[0] => Array
(
[appid] => 730
[contextid] => 2
[assetid] => 4974401193
[classid] => 319730196
[instanceid] => 188530139
[amount] => 1
[missing] =>
)
)
[items_to_receive] => Array
(
[0] => Array
(
[appid] => 730
[contextid] => 2
[assetid] => 4981322842
[classid] => 311848115
[instanceid] => 188530139
[amount] => 1
[missing] =>
)
[1] => Array
(
[appid] => 730
[contextid] => 2
[assetid] => 3600963191
[classid] => 350875311
[instanceid] => 480085569
[amount] => 1
[missing] =>
)
)
[is_our_offer] =>
[time_created] => 1454258239
[time_updated] => 1454258249
[from_real_time_trade] =>
[escrow_end_date] => 0
[confirmation_method] => 0
)
[1] => Array
(
[tradeofferid] => 988791916
[accountid_other] => 55306956
[message] => fv 0.1616 nice look
[expiration_time] => 1455466526
[trade_offer_state] => 2
[items_to_give] => Array
(
[0] => Array
(
[appid] => 730
[contextid] => 2
[assetid] => 4974401224
[classid] => 311236182
[instanceid] => 188530139
[amount] => 1
[missing] =>
)
)
[items_to_receive] => Array
(
[0] => Array
(
[appid] => 730
[contextid] => 2
[assetid] => 4985509468
[classid] => 310992880
[instanceid] => 188530139
[amount] => 1
[missing] =>
)
)
[is_our_offer] =>
[time_created] => 1454256926
[time_updated] => 1454256936
[from_real_time_trade] =>
[escrow_end_date] => 0
[confirmation_method] => 0
)
)
)
)
trade_offers_receivedobject first, then access thetime_createdattribute inside each iteration.TRUEparam from thejson_decode()