3v4l.org

run code in 300+ PHP versions simultaneously
<?php // DBからSQLでソートするためにセットされてるダミー日付 define( 'DATE_DAMMY', '1970-01-01 00:00:00' ); // DBからとってきた生レコード $content_row = [ // コメントの情報 'content_id' => 1 ,'content_content' => 'かわいいですね' ,'content_kind' => 'comment' ,'date_create' => '2020-02-01 00:00:01' // コメントが投稿された日 ,'date_his_create' => '1970-01-01 00:00:00' // 自分が投稿したらここも入る ,'date_vote_up' => '2020-02-01 00:00:02' // 自分がコメントを高評価した日 ,'date_clip' => '1970-01-01 00:00:00' // 自分がコメントを保存した日 // 掲示板の情報 ,'parent_content_id' => 10 ,'parent_title' => '猫の掲示板' ,'parent_content_kind' => 'thread' ,'parent_date_favorite' => '1970-01-01 00:00:00' // 自分が掲示板へいいねした日 // コメントの投稿者の情報 ,'author_content_id' => 100 ,'author_content_content' => '花子' ,'author_date_follow' => '2020-01-01 00:00:00' // 自分が投稿者をフォローした日 ]; // 生レコードである $content_row を $content_info へ調整 $content_info = assort($content_row); var_dump($content_info); function assort( $content_row ){ $content_info = []; foreach( $content_row as $k => $v ){ // 掲示板の情報をまとめる if( str_exist($k,'parent') ){ $key = str_replace('parent_','',$k); $content_info['parent_info'][$key] = $v; } // 投稿者の情報をまとめる elseif( str_exist($k,'author') ){ $key = str_replace('author_','',$k); $content_info['author_info'][$key] = $v; $content_info['author_info']['service_name'] = 'mysite'; $content_info['author_info']['kind'] = 'user'; } // コメントの情報 else{ // 日付 if( str_exist($k,'date') ){ // ダミー日付は入れない if( $v == DATE_DAMMY ) continue; // そのまま入れる $content_info[$k] = $v; // jsでソートするときキーが不定だと処理が遅いのでここで date_latest としてソートキーを統一しておく if( !isset($content_info['date_latest']) ){ // まずこの if でなんでもいいので最新日としてセットして、次の else で新しいものに更新していく $content_info['date_latest'] = $v; }else{ // 新しいものに更新していく $date_latest = ( $v > $content_info['date_latest'] ) ? $v : $content_info['date_latest']; $content_info['date_latest'] = $date_latest; } // 判定系はDBでは 0|1 になってるので真偽値にしておく }elseif( str_exist($k,'is_') ){ $content_info[$k] = $v == 1 ? true : false; // 他 }else{ // そのまま入れる $content_info[$k] = $v; } } } return $content_info; } // strpos の代わり function str_exist( $target, $str ){ $is = false; // 配列渡したらエラー if( is_array($target) || is_array($str) ){ error_log('str_exist() : $target - $str : ' . json_encode($target) . ' - ' . json_encode($str) ); } // 普通の strpos を実行 if(strpos($target,$str) !== false){ $is = true; } return $is; }

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.120.0080.00720.73
8.4.110.0040.00522.27
8.4.100.0250.00619.28
8.4.90.0100.00920.71
8.4.80.0420.00717.70
8.4.70.0330.00717.79
8.4.60.0320.00817.76
8.4.50.0340.00817.69
8.4.40.0320.00717.57
8.4.30.0340.00817.60
8.4.20.0330.00817.51
8.4.10.0310.00817.56
8.3.250.0110.00919.05
8.3.240.0080.00517.04
8.3.230.0110.00816.45
8.3.220.0280.00617.04
8.3.210.0270.00617.03
8.3.200.0280.00717.04
8.3.190.0280.00517.05
8.3.180.0270.00717.04
8.3.170.0300.00716.97
8.3.160.0290.00616.98
8.3.150.0280.00616.97
8.3.140.0270.00616.96
8.3.130.0200.00517.02
8.3.120.0210.00617.05
8.3.110.0230.00617.11
8.3.100.0270.00617.21
8.3.90.0280.00617.33
8.3.80.0290.00617.03
8.3.70.0280.00616.96
8.3.60.0260.00517.01
8.3.50.0260.00617.43
8.3.40.0260.00617.71
8.3.30.0230.00617.54
8.3.20.0240.00617.78
8.3.10.0230.00717.73
8.3.00.0210.00617.84
8.2.290.0130.00416.55
8.2.280.0240.00617.07
8.2.270.0260.00716.97
8.2.260.0270.00616.98
8.2.250.0270.00616.97
8.2.240.0270.00617.01
8.2.230.0260.00617.24
8.2.220.0270.00717.71
8.2.210.0260.00717.31
8.2.200.0270.00716.95
8.2.190.0270.00616.98
8.2.180.0280.00717.27
8.2.170.0300.00617.69
8.2.160.0300.00617.83
8.2.150.0280.00617.94
8.2.140.0240.00617.81
8.2.130.0280.00717.76
8.2.120.0280.00617.69
8.2.110.0300.00617.73
8.2.100.0300.00717.56
8.2.90.0290.00717.62
8.2.80.0280.00617.53
8.2.70.0280.00717.46
8.2.60.0260.00717.50
8.2.50.0270.00617.49
8.2.40.0270.00717.62
8.2.30.0300.00717.51
8.2.20.0250.00617.53
8.2.10.0260.00717.55
8.2.00.0260.00617.55
8.1.330.0120.00616.50
8.1.320.0250.00616.93
8.1.310.0280.00616.91
8.1.300.0290.00716.91
8.1.290.0290.00717.44
8.1.280.0280.00717.26
8.1.270.0290.00717.56
8.1.260.0260.00717.63
8.1.250.0270.00717.65
8.1.240.0270.00717.56
8.1.230.0250.00717.44
8.1.220.0270.00717.47
8.1.210.0280.00717.37
8.1.200.0300.00717.32
8.1.190.0300.00817.21
8.1.180.0280.00717.28
8.1.170.0280.00817.37
8.1.160.0290.00717.35
8.1.150.0280.00617.31
8.1.140.0300.00817.37
8.1.130.0280.00717.40
8.1.120.0270.00617.37
8.1.110.0300.00717.33
8.1.100.0250.00717.25
8.1.90.0250.00717.26
8.1.80.0260.00717.29
8.1.70.0280.00717.28
8.1.60.0290.00617.38
8.1.50.0260.00817.35
8.1.40.0250.00717.48
8.1.30.0260.00717.44
8.1.20.0260.00817.47
8.1.10.0250.00617.34
8.1.00.0250.00617.20
8.0.300.0250.00617.04
8.0.290.0250.00616.97
8.0.280.0270.00617.02
8.0.270.0280.00717.00
8.0.260.0260.00717.02
8.0.250.0270.00617.05
8.0.240.0260.00716.98
8.0.230.0260.00616.99
8.0.220.0260.00616.95
8.0.210.0270.00616.98
8.0.200.0250.00616.98
8.0.190.0240.00616.98
8.0.180.0270.00616.98
8.0.170.0260.00716.98
8.0.160.0280.00716.97
8.0.150.0250.00616.98
8.0.140.0260.00616.97
8.0.130.0260.00616.85
8.0.120.0280.00716.97
8.0.110.0270.00716.97
8.0.100.0290.00716.97
8.0.90.0270.00616.97
8.0.80.0270.00717.04
8.0.70.0280.00616.97
8.0.60.0260.00616.97
8.0.50.0260.00716.96
8.0.30.0260.00616.98
8.0.20.0250.00616.97
8.0.10.0250.00616.99
8.0.00.0250.00716.98
7.4.330.0270.00516.97
7.4.320.0250.00616.94
7.4.300.0220.00616.94
7.4.290.0230.00616.94
7.4.280.0250.00616.94
7.4.270.0250.00616.93
7.4.260.0240.00616.83
7.4.250.0250.00616.94
7.4.240.0240.00616.95
7.4.230.0250.00616.95
7.4.220.0250.00616.93
7.4.210.0240.00716.92
7.4.200.0240.00716.94
7.4.190.0270.00616.97
7.4.180.0250.00616.94
7.4.160.0260.00616.95
7.4.150.0240.00516.95
7.4.140.0240.00616.96
7.4.130.0250.00616.92
7.4.120.0250.00616.93
7.4.110.0260.00716.93
7.4.100.0240.00616.92
7.4.90.0240.00616.93
7.4.80.0250.00616.93
7.4.70.0260.00516.93
7.4.60.0250.00616.94
7.4.50.0260.00617.00
7.4.40.0250.00616.92
7.4.30.0250.00616.94
7.4.20.0240.00716.99
7.4.10.0230.00616.94
7.4.00.0250.00716.95
7.3.330.0250.00616.98
7.3.320.0230.00616.82
7.3.310.0230.00616.93
7.3.300.0250.00616.93
7.3.290.0240.00716.88
7.3.280.0240.00616.95
7.3.270.0250.00616.95
7.3.260.0250.00616.97
7.3.250.0240.00616.95
7.3.240.0240.00616.92
7.3.230.0240.00616.94
7.3.220.0250.00716.92
7.3.210.0250.00616.94
7.3.200.0250.00616.93
7.3.190.0260.00716.93
7.3.180.0260.00616.92
7.3.170.0250.00616.99
7.3.160.0260.00616.92
7.3.150.0270.00616.92
7.3.140.0260.00616.93
7.3.130.0270.00616.93
7.3.120.0240.00616.92
7.3.110.0220.00616.92
7.3.100.0230.00616.92
7.3.90.0240.00616.94
7.3.80.0270.00616.92
7.3.70.0240.00716.98
7.3.60.0240.00616.94
7.3.50.0250.00616.92
7.3.40.0250.00616.92
7.3.30.0250.00616.92
7.3.20.0300.00717.71
7.3.10.0260.00617.62
7.3.00.0250.00517.67
7.2.340.0240.00816.97
7.2.330.0250.00816.97
7.2.320.0300.00616.97
7.2.310.0280.00716.97
7.2.300.0270.00816.97
7.2.290.0260.00716.97
7.2.280.0220.00616.97
7.2.270.0280.00616.97
7.2.260.0260.00916.97
7.2.250.0270.00816.97
7.2.240.0270.00716.97
7.2.230.0290.00816.97
7.2.220.0290.00716.97
7.2.210.0260.00916.97
7.2.200.0260.00616.97
7.2.190.0150.00516.97
7.2.180.0210.00616.97
7.2.170.0260.00516.97
7.2.160.0280.00716.97
7.2.150.0320.00718.16
7.2.140.0310.00718.18
7.2.130.0310.00518.29
7.2.120.0230.00618.19
7.2.110.0170.00418.36
7.2.100.0160.00618.24
7.2.90.0210.00718.25
7.2.80.0230.00918.28
7.2.70.0220.00718.27
7.2.60.0300.00818.19
7.2.50.0310.00718.31
7.2.40.0300.00518.14
7.2.30.0290.00918.20
7.2.20.0240.00618.47
7.2.10.0220.00718.37
7.2.00.0260.00418.34
7.1.330.0230.00916.97
7.1.320.0250.01016.97
7.1.310.0140.00717.37
7.1.300.0280.01117.03
7.1.290.0210.00917.04
7.1.280.0240.00516.99
7.1.270.0240.00817.14
7.1.260.0260.00616.98
7.1.250.0270.00516.97
7.1.240.0250.00616.97
7.1.230.0110.00417.36
7.1.220.0140.00317.09
7.1.210.0100.00517.06
7.1.200.0150.00617.10
7.1.190.0240.00917.00
7.1.180.0230.00617.11
7.1.170.0180.01117.12
7.1.160.0260.00416.97
7.1.150.0240.00916.97
7.1.140.0290.00816.99
7.1.130.0280.00817.06
7.1.120.0220.00717.17
7.1.110.0200.01017.29
7.1.100.0220.00817.21
7.1.90.0100.00517.02
7.1.80.0130.00917.23
7.1.70.0190.00617.03
7.1.60.0250.00816.98
7.1.50.0310.00817.31
7.1.40.0090.00517.22
7.1.30.0220.00717.11
7.1.20.0150.00517.30
7.1.10.0160.00316.98
7.1.00.0140.00416.97
7.0.330.0250.00617.05
7.0.320.0210.00516.97
7.0.310.0280.00416.97
7.0.300.0290.00616.97
7.0.290.0230.00716.97
7.0.280.0100.00416.97
7.0.270.0100.00416.97
7.0.260.0270.00516.97
7.0.250.0270.00516.97
7.0.240.0210.00817.00
7.0.230.0110.00316.97
7.0.220.0110.00317.07
7.0.210.0250.00617.07
7.0.200.0260.00517.06
7.0.190.0270.00716.97
7.0.180.0170.01016.97
7.0.170.0150.00416.97
7.0.160.0240.00216.97
7.0.150.0270.00516.97
7.0.140.0230.00916.97
7.0.130.0250.00616.97
7.0.120.0250.00616.97
7.0.110.0240.00717.04
7.0.100.0260.00517.01
7.0.90.0260.00516.97
7.0.80.0250.00616.97
7.0.70.0240.00716.97
7.0.60.0220.00616.97
7.0.50.0240.00216.97
7.0.40.0280.00616.97
7.0.30.0250.01116.97
7.0.20.0210.01016.97
7.0.10.0260.00616.97
7.0.00.0240.00816.97
5.6.400.0230.00916.97
5.6.390.0300.00316.97
5.6.380.0240.00816.97
5.6.370.0240.00916.97
5.6.360.0300.00616.97
5.6.350.0330.00616.97
5.6.340.0300.00416.97
5.6.330.0270.00616.97
5.6.320.0250.00516.97
5.6.310.0270.00416.97
5.6.300.0220.00816.97
5.6.290.0260.00616.97
5.6.280.0300.00316.97
5.6.270.0230.00516.97
5.6.260.0310.00816.97
5.6.250.0190.00916.97
5.6.240.0290.00316.97
5.6.230.0220.01016.97
5.6.220.0220.00716.97
5.6.210.0210.00716.97
5.6.200.0260.00616.97
5.6.190.0190.00216.97
5.6.180.0110.00316.97
5.6.170.0160.00316.97
5.6.160.0200.00516.97
5.6.150.0320.00216.97
5.6.140.0290.00616.97
5.6.130.0260.00616.97
5.6.120.0160.00216.97
5.6.110.0250.00316.97
5.6.100.0270.00616.97
5.6.90.0220.00916.97
5.6.80.0230.00916.97
5.6.70.0250.00716.97
5.6.60.0250.00716.97
5.6.50.0240.00716.97
5.6.40.0150.00516.97
5.6.30.0230.00716.97
5.6.20.0180.00116.97
5.6.10.0140.00716.97
5.6.00.0230.00716.97
5.5.380.0270.00416.97
5.5.370.0170.00816.97
5.5.360.0160.00216.97
5.5.350.0160.00616.97
5.5.340.0120.00316.97
5.5.330.0110.00416.97
5.5.320.0130.00416.97
5.5.310.0190.00716.97
5.5.300.0280.00416.97
5.5.290.0240.00816.97
5.5.280.0260.00616.97
5.5.270.0250.00516.97
5.5.260.0260.00816.97
5.5.250.0380.00616.97
5.5.240.0240.00716.97
5.5.230.0360.01016.97
5.5.220.0310.00316.97
5.5.210.0130.00616.97
5.5.200.0260.00516.97
5.5.190.0210.00816.97
5.5.180.0240.00716.97
5.5.170.0200.00616.97
5.5.160.0240.00516.97
5.5.150.0210.01016.97
5.5.140.0320.00616.97
5.5.130.0190.00716.97
5.5.120.0100.00416.97
5.5.110.0190.00616.97
5.5.100.0150.00516.97
5.5.90.0220.00616.97
5.5.80.0200.00816.97
5.5.70.0160.01416.97
5.5.60.0230.00816.97
5.5.50.0200.00816.97
5.5.40.0120.00216.97
5.5.30.0210.00516.97
5.5.20.0190.00216.97
5.5.10.0210.00716.97
5.5.00.0120.00216.97
5.4.450.0140.00116.97
5.4.440.0130.00316.97
5.4.430.0080.00416.97
5.4.420.0090.00216.97
5.4.410.0140.00816.97
5.4.400.0110.00316.97
5.4.390.0080.00316.97
5.4.380.0080.00316.97
5.4.370.0070.00416.97
5.4.360.0190.00316.97
5.4.350.0190.00616.97
5.4.340.0180.00716.97
5.4.330.0150.00916.97
5.4.320.0180.00516.97
5.4.310.0170.00616.97
5.4.300.0220.00316.97
5.4.290.0190.00516.97
5.4.280.0210.00416.97
5.4.270.0230.00116.97
5.4.260.0200.00616.97
5.4.250.0180.00416.97
5.4.240.0070.00516.97
5.4.230.0270.00516.97
5.4.220.0260.00516.97
5.4.210.0130.00316.97
5.4.200.0100.00116.97
5.4.190.0180.00616.97
5.4.180.0200.00416.97
5.4.170.0150.00316.97
5.4.160.0200.00516.97
5.4.150.0200.00516.97
5.4.140.0120.00516.97
5.4.130.0070.00516.97
5.4.120.0100.00216.97
5.4.110.0080.00316.97
5.4.100.0120.00216.97
5.4.90.0110.00116.97
5.4.80.0080.00316.97
5.4.70.0120.00216.97
5.4.60.0240.00416.97
5.4.50.0110.00116.97
5.4.40.0120.00116.97
5.4.30.0090.00216.97
5.4.20.0120.00216.97
5.4.10.0090.00316.97
5.4.00.0170.00416.97
5.3.290.0130.00716.97
5.3.280.0190.00416.97
5.3.270.0080.00416.97
5.3.260.0080.00316.97
5.3.250.0100.00216.97
5.3.240.0070.00616.97
5.3.230.0190.00316.97
5.3.220.0090.00216.97
5.3.210.0070.00416.97
5.3.200.0170.00716.97
5.3.190.0180.00316.97
5.3.180.0160.00616.97
5.3.170.0210.00516.97
5.3.160.0140.00416.97
5.3.150.0150.00016.97
5.3.140.0070.00416.97
5.3.130.0160.00716.97
5.3.120.0190.00316.97
5.3.110.0080.00416.97
5.3.100.0080.00316.97
5.3.90.0090.00216.97
5.3.80.0080.00316.97
5.3.70.0070.00416.97
5.3.60.0080.00216.97
5.3.50.0090.00216.97
5.3.40.0240.00516.97
5.3.30.0240.00216.97
5.3.20.0220.00616.97
5.3.10.0180.00516.97
5.3.00.0180.00616.97
5.2.170.0160.00616.97
5.2.160.0160.00416.97
5.2.150.0160.00316.97
5.2.140.0160.00416.97
5.2.130.0160.00416.97
5.2.120.0160.00416.97
5.2.110.0140.00516.97
5.2.100.0160.00416.97
5.2.90.0140.00616.97
5.2.80.0140.00516.97
5.2.70.0140.00616.97
5.2.60.0150.00516.97
5.2.50.0170.00316.97
5.2.40.0110.00816.97
5.2.30.0110.01016.97
5.2.20.0150.00816.97
5.2.10.0130.00416.97
5.2.00.0150.00316.97
5.1.60.0160.00516.97
5.1.50.0140.00316.97
5.1.40.0130.00416.97
5.1.30.0110.00716.97
5.1.20.0120.00516.97
5.1.10.0130.00416.97
5.1.00.0100.00716.97
5.0.50.0110.00416.97
5.0.40.0110.00416.97
5.0.30.0160.00216.97
5.0.20.0150.00216.97
5.0.10.0140.00116.97
5.0.00.0070.00416.97
4.4.90.0080.00016.97
4.4.80.0080.00216.97
4.4.70.0090.00116.97
4.4.60.0060.00316.97
4.4.50.0050.00316.97
4.4.40.0090.00016.97
4.4.30.0070.00216.97
4.4.20.0070.00116.97
4.4.10.0060.00316.97
4.4.00.0090.00016.97
4.3.110.0060.00316.97
4.3.100.0080.00116.97
4.3.90.0060.00216.97
4.3.80.0070.00116.97
4.3.70.0070.00216.97
4.3.60.0070.00216.97
4.3.50.0070.00216.97
4.3.40.0080.00016.97
4.3.30.0060.00116.97
4.3.20.0060.00116.97
4.3.10.0070.00016.97
4.3.00.0070.00016.97

preferences:
86.24 ms | 403 KiB | 5 Q