3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array_question = '[ { "id": "8", "question": "Shop sign/billboard " }, { "id": "10", "question": "Pylon" }, { "id": "11", "question": "Banner" }, { "id": "12", "question": "Sport" }, { "id": "14", "question": "Matic " }, { "id": "16", "question": "Cub" } ]'; $array_answer = '[ { "id": "1b9fa84e-0f2f-11e9-b673-005056be36b2", "answer": "3", "id_question": "16" }, { "id": "bc82c3fd-0f2e-11e9-b673-005056be36b2", "answer": "1", "id_question": "11" }, { "id": "cc9363f1-0f2e-11e9-b673-005056be36b2", "answer": "3", "id_question": "12" }, { "id": "f1dfa8b5-0f2e-11e9-b673-005056be36b2", "answer": "1", "id_question": "14" } ]'; $questions = json_decode($array_question); $answers = json_decode($array_answer, true); function my_array_column($array, $column) { return array_map(function ($v) use ($column) { return $v[$column]; }, $array); } $array_result = array_map(function ($v) use ($answers) { $v->answer = ($k = array_search($v->id, my_array_column($answers, 'id_question'))) !== false ? $answers[$k]['answer'] : null; return $v; }, $questions); echo str_replace('\/', '/', json_encode($array_result));

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.0.30.0100.00816.96
8.0.20.0160.01017.18
8.0.00.0110.01116.78
7.4.160.0090.00816.46
7.4.140.0100.01017.86
7.4.130.0030.01616.40
7.4.120.0090.00916.55
7.4.110.0170.00016.50
7.4.100.0140.00916.56
7.4.90.0120.00916.50
7.4.80.0090.01119.39
7.4.70.0090.00916.45
7.4.60.0060.00916.52
7.4.50.0080.00816.55
7.4.40.0060.01016.36
7.4.00.0070.00714.94
7.3.280.0070.01216.36
7.3.260.0100.00916.42
7.3.240.0060.01016.45
7.3.230.0140.00316.59
7.3.210.0070.00716.59
7.3.200.0090.00916.68
7.3.190.0130.00316.62
7.3.180.0040.01216.39
7.3.170.0110.00616.37
7.3.160.0040.01216.41
7.3.10.0060.00616.55
7.3.00.0140.00915.98
7.2.330.0110.00616.43
7.2.320.0090.00916.83
7.2.310.0030.01616.70
7.2.300.0090.00916.56
7.2.290.0100.00716.89
7.2.130.0230.01016.32
7.2.120.0170.00916.29
7.2.110.0150.00816.40
7.2.100.0300.00416.38
7.2.90.0180.00816.36
7.2.80.0570.00716.25
7.2.70.0160.00816.36
7.2.60.0220.00716.20
7.2.50.0190.00416.26
7.2.40.0220.00516.29
7.2.30.0240.00816.39
7.2.20.0140.01016.40
7.2.10.0240.00616.33
7.2.00.0170.00716.38
7.1.250.0150.00715.03