PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
/* #Запрос который отправляю [{ "user_tg_id": "{{this_user.platform_id}}", "user_points": "{{all_point}}" }] */
Copy Clear
Copy Format Clear
<?php #Получаю $responce = ' [[{ "user_tg_id": "1004772763", "user_points": "200" }],[{ "user_tg_id": "1004772763", "user_points": "200" }],[{ "user_tg_id": "1004772763", "user_points": "240" }]]'; // parce JSON data to PHP array $data = json_decode($responce, true); //print_r($data); $result = []; foreach($data as $d) { $user_tg_id = $d[0]['user_tg_id']; $user_points = $d[0]['user_points']; if (isset($result[$user_tg_id])) { $result[$user_tg_id] = max($result[$user_tg_id], $user_points); } else { $result[$user_tg_id] = $user_points; } } print_r(json_encode($result, true));
Show:  
Copy Clear