@ 2024-11-21T09:33:50Z <?php
error_reporting(-1);
ini_set('display_errors', 1);
$json_data = <<<JSON
{"messages": [
{
"id": 1,
"customer": "Dr. Kane Hill",
"customer_id": 1,
"created_at": "2024-11-19 11:18:57",
"text": "Hello, how are you?"
},
{
"id": 2,
"customer": "Dr. Kane Hill",
"customer_id": 1,
"created_at": "2024-11-19 11:20:57",
"text": "I am good, thanks! How about you?"
},
{
"id": 3,
"customer": "Prof. Samir McClure III",
"customer_id": 2,
"created_at": "2024-11-19 11:21:57",
"text": "Hey, what time is it?"
},
{
"id": 4,
"customer": "Prof. Samir McClure III",
"customer_id": 2,
"created_at": "2024-11-19 11:22:57",
"text": "It is 3 PM."
},
{
"id": 5,
"customer": "Shad Leffler",
"customer_id": 3,
"created_at": "2024-11-19 11:23:57",
"text": "Did you finish the project?"
},
{
"id": 6,
"customer": "Shad Leffler",
"customer_id": 3,
"created_at": "2024-11-19 11:24:57",
"text": "New mesh"
},
{
"id": 7,
"customer": "Prof. Samir McClure III",
"customer_id": 2,
"created_at": "2024-11-19 11:26:57",
"text": "Not bed?"
},
{
"id": 8,
"customer": "Prof. Samir McClure III",
"customer_id": 2,
"created_at": "2024-11-19 11:27:57",
"text": "Cool?"
}
]}
JSON;
$messages = json_decode($json_data, true)['messages'];
$messages2 = [];
$messageCounter = 0;
foreach($messages as $row) {
$key = $row['customer_id'];
if(!isset($messages2[$key])) {
$messages2[$key] = [
'customer' => $row['customer'],
'message_id' => (++$messageCounter),
'customer_id' => $row['customer_id'],
'messages' => [],
];
}
$messages2[$key]['messages'][] = [
'id' => $row['id'],
'created_at' => $row['created_at'],
'text' => $row['text'],
];
}
$messages2 = array_values($messages2);
echo json_encode($messages2, JSON_PRETTY_PRINT);
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Version System time (s) User time (s) Memory (MiB) 8.4.13 0.010 0.007 18.03 8.4.12 0.005 0.007 20.63 8.4.11 0.008 0.003 18.88 8.4.10 0.014 0.008 17.71 8.4.9 0.014 0.007 18.51 8.4.8 0.012 0.009 17.71 8.4.7 0.004 0.005 18.04 8.4.6 0.011 0.009 19.38 8.4.5 0.011 0.009 20.47 8.4.4 0.007 0.013 18.65 8.4.3 0.004 0.004 18.95 8.4.2 0.010 0.010 21.45 8.4.1 0.004 0.004 19.27 8.3.26 0.011 0.008 16.60 8.3.25 0.014 0.005 18.80 8.3.24 0.014 0.006 16.80 8.3.23 0.012 0.007 16.57 8.3.22 0.005 0.003 17.05 8.3.21 0.009 0.008 16.54 8.3.20 0.009 0.010 16.73 8.3.19 0.012 0.006 17.25 8.3.18 0.014 0.005 18.89 8.3.17 0.007 0.011 17.11 8.3.16 0.011 0.007 18.36 8.3.15 0.011 0.007 16.93 8.3.14 0.006 0.003 18.52 8.3.13 0.013 0.007 16.67 8.3.12 0.000 0.008 16.52 8.3.5 0.004 0.004 16.69 8.2.29 0.009 0.011 20.43 8.2.28 0.008 0.007 16.38 8.2.27 0.015 0.000 16.79 8.2.26 0.005 0.003 17.49 8.2.25 0.011 0.004 18.34 8.1.33 0.004 0.003 22.06 8.1.32 0.013 0.007 15.96 8.1.31 0.009 0.006 16.54
preferences:dark mode live preview ace vim emacs key bindings
20.03 ms | 403 KiB | 5 Q