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.130.0280.01017.61
8.4.120.0300.00718.17
8.4.110.0320.00818.66
8.4.100.0290.00818.23
8.4.90.0310.00818.40
8.4.80.0400.00717.69
8.4.70.0330.00817.76
8.4.60.0330.00817.73
8.4.50.0340.00817.69
8.4.40.0330.00717.56
8.4.30.0340.00817.59
8.4.20.0340.00817.51
8.4.10.0310.00717.56
8.3.260.0200.00516.52
8.3.250.0260.00516.91
8.3.240.0200.00616.52
8.3.230.0290.00516.52
8.3.220.0280.00616.95
8.3.210.0290.00617.04
8.3.200.0290.00716.98
8.3.190.0280.00516.97
8.3.180.0270.00716.97
8.3.170.0300.00716.93
8.3.160.0300.00716.92
8.3.150.0290.00616.91
8.3.140.0280.00616.89
8.3.130.0220.00516.95
8.3.120.0230.00616.96
8.3.110.0240.00617.02
8.3.100.0280.00617.12
8.3.90.0290.00717.22
8.3.80.0300.00616.96
8.3.70.0290.00616.89
8.3.60.0270.00616.95
8.3.50.0260.00617.32
8.3.40.0260.00617.67
8.3.30.0240.00617.53
8.3.20.0250.00617.75
8.3.10.0240.00717.69
8.3.00.0220.00617.81
8.2.290.0270.00616.56
8.2.280.0240.00717.01
8.2.270.0260.00716.93
8.2.260.0270.00616.93
8.2.250.0270.00616.91
8.2.240.0260.00616.94
8.2.230.0260.00717.15
8.2.220.0270.00717.55
8.2.210.0260.00617.19
8.2.200.0260.00716.86
8.2.190.0270.00616.92
8.2.180.0280.00717.14
8.2.170.0300.00717.67
8.2.160.0320.00617.79
8.2.150.0290.00617.91
8.2.140.0260.00617.77
8.2.130.0280.00717.71
8.2.120.0290.00617.67
8.2.110.0300.00717.69
8.2.100.0300.00717.57
8.2.90.0290.00717.62
8.2.80.0290.00617.53
8.2.70.0280.00717.45
8.2.60.0270.00717.49
8.2.50.0270.00617.50
8.2.40.0270.00717.60
8.2.30.0300.00717.51
8.2.20.0260.00617.51
8.2.10.0270.00717.55
8.2.00.0260.00617.55
8.1.330.0290.00816.05
8.1.320.0260.00716.84
8.1.310.0280.00616.82
8.1.300.0290.00716.80
8.1.290.0300.00717.27
8.1.280.0280.00717.11
8.1.270.0290.00717.53
8.1.260.0260.00717.58
8.1.250.0280.00717.61
8.1.240.0270.00717.52
8.1.230.0250.00717.42
8.1.220.0280.00717.43
8.1.210.0280.00717.36
8.1.200.0300.00717.32
8.1.190.0300.00717.21
8.1.180.0280.00717.27
8.1.170.0280.00817.36
8.1.160.0290.00717.34
8.1.150.0290.00717.30
8.1.140.0300.00817.34
8.1.130.0290.00717.38
8.1.120.0280.00617.37
8.1.110.0300.00717.33
8.1.100.0260.00717.24
8.1.90.0260.00717.26
8.1.80.0260.00717.29
8.1.70.0280.00717.28
8.1.60.0290.00617.38
8.1.50.0270.00817.35
8.1.40.0260.00717.47
8.1.30.0260.00617.44
8.1.20.0260.00717.45
8.1.10.0250.00717.35
8.1.00.0250.00617.19
8.0.300.0260.00616.99
8.0.290.0260.00616.91
8.0.280.0280.00616.97
8.0.270.0280.00716.94
8.0.260.0260.00716.97
8.0.250.0280.00617.00
8.0.240.0260.00716.93
8.0.230.0260.00616.95
8.0.220.0260.00616.91
8.0.210.0270.00616.93
8.0.200.0260.00616.92
8.0.190.0250.00616.92
8.0.180.0270.00616.94
8.0.170.0270.00716.95
8.0.160.0280.00716.93
8.0.150.0260.00616.92
8.0.140.0270.00616.92
8.0.130.0270.00716.82
8.0.120.0280.00716.92
8.0.110.0270.00716.92
8.0.100.0290.00716.90
8.0.90.0270.00616.92
8.0.80.0260.00616.97
8.0.70.0280.00616.91
8.0.60.0260.00616.91
8.0.50.0260.00616.91
8.0.30.0260.00616.92
8.0.20.0260.00616.91
8.0.10.0260.00716.95
8.0.00.0250.00716.94
7.4.330.0270.00616.88
7.4.320.0260.00616.85
7.4.300.0230.00616.85
7.4.290.0230.00616.85
7.4.280.0260.00616.86
7.4.270.0250.00616.84
7.4.260.0240.00616.76
7.4.250.0250.00616.84
7.4.240.0240.00616.88
7.4.230.0250.00516.86
7.4.220.0250.00616.83
7.4.210.0230.00716.83
7.4.200.0240.00716.86
7.4.190.0260.00616.88
7.4.180.0250.00616.84
7.4.160.0250.00616.85
7.4.150.0240.00516.86
7.4.140.0240.00516.84
7.4.130.0240.00616.82
7.4.120.0250.00616.83
7.4.110.0250.00716.84
7.4.100.0240.00616.84
7.4.90.0240.00616.83
7.4.80.0250.00616.83
7.4.70.0250.00516.84
7.4.60.0250.00616.84
7.4.50.0260.00616.89
7.4.40.0250.00616.82
7.4.30.0250.00616.84
7.4.20.0240.00616.89
7.4.10.0230.00616.83
7.4.00.0250.00616.84
7.3.330.0250.00616.86
7.3.320.0230.00516.72
7.3.310.0220.00516.83
7.3.300.0250.00616.83
7.3.290.0240.00716.78
7.3.280.0240.00616.83
7.3.270.0250.00616.84
7.3.260.0240.00616.86
7.3.250.0230.00616.83
7.3.240.0240.00616.82
7.3.230.0250.00616.84
7.3.220.0250.00716.82
7.3.210.0250.00616.82
7.3.200.0250.00616.81
7.3.190.0250.00716.81
7.3.180.0260.00616.80
7.3.170.0250.00616.87
7.3.160.0250.00616.79
7.3.150.0260.00616.81
7.3.140.0260.00616.81
7.3.130.0270.00716.81
7.3.120.0240.00616.80
7.3.110.0220.00616.79
7.3.100.0240.00616.79
7.3.90.0250.00616.84
7.3.80.0270.00616.82
7.3.70.0250.00616.87
7.3.60.0240.00616.86
7.3.50.0250.00616.84
7.3.40.0250.00616.83
7.3.30.0250.00616.84
7.3.20.0290.00717.64
7.3.10.0260.00617.54
7.3.00.0250.00617.59
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

preferences:
31.19 ms | 403 KiB | 5 Q