3v4l.org

run code in 300+ PHP versions simultaneously
<?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);

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).

VersionSystem time (s)User time (s)Memory (MiB)
8.4.130.0100.00718.03
8.4.120.0050.00720.63
8.4.110.0080.00318.88
8.4.100.0140.00817.71
8.4.90.0140.00718.51
8.4.80.0120.00917.71
8.4.70.0040.00518.04
8.4.60.0110.00919.38
8.4.50.0110.00920.47
8.4.40.0070.01318.65
8.4.30.0040.00418.95
8.4.20.0100.01021.45
8.4.10.0040.00419.27
8.3.260.0110.00816.60
8.3.250.0140.00518.80
8.3.240.0140.00616.80
8.3.230.0120.00716.57
8.3.220.0050.00317.05
8.3.210.0090.00816.54
8.3.200.0090.01016.73
8.3.190.0120.00617.25
8.3.180.0140.00518.89
8.3.170.0070.01117.11
8.3.160.0110.00718.36
8.3.150.0110.00716.93
8.3.140.0060.00318.52
8.3.130.0130.00716.67
8.3.120.0000.00816.52
8.3.50.0040.00416.69
8.2.290.0090.01120.43
8.2.280.0080.00716.38
8.2.270.0150.00016.79
8.2.260.0050.00317.49
8.2.250.0110.00418.34
8.1.330.0040.00322.06
8.1.320.0130.00715.96
8.1.310.0090.00616.54

preferences:
20.03 ms | 403 KiB | 5 Q