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.60.0150.00718.46
8.4.50.0270.00717.76
8.4.40.0220.00417.36
8.4.30.0170.00518.94
8.4.20.0260.00717.61
8.4.10.0130.00418.69
8.3.200.0040.00416.80
8.3.190.0150.00217.69
8.3.180.0130.00617.74
8.3.170.0170.00916.51
8.3.160.0220.00516.85
8.3.150.0150.00516.77
8.3.140.0150.00716.59
8.3.130.0100.00717.43
8.3.120.0140.00517.78
8.3.110.0120.00218.60
8.3.100.0100.00520.20
8.3.90.0120.00321.61
8.3.80.0080.00717.48
8.3.70.0180.00416.54
8.3.60.0150.00417.32
8.3.50.0130.00821.33
8.3.40.0110.00619.58
8.3.30.0120.00418.16
8.3.20.0130.00421.68
8.3.10.0140.00621.12
8.3.00.0120.00521.87
8.2.280.0110.00318.12
8.2.270.0210.01016.59
8.2.260.0220.00416.54
8.2.250.0150.00516.60
8.2.240.0140.00617.33
8.2.230.0110.00520.46
8.2.220.0150.00527.12
8.2.210.0110.00421.61
8.2.200.0160.00616.53
8.2.190.0200.00616.64
8.2.180.0170.00921.03
8.2.170.0160.00818.17
8.2.160.0230.00220.32
8.2.150.0190.00322.50
8.2.140.0110.00621.96
8.2.130.0140.00721.89
8.2.120.0080.00519.22
8.2.110.0100.00419.83
8.2.100.0110.00517.48
8.2.90.0100.00517.57
8.2.80.0120.00218.26
8.2.70.0120.00817.51
8.2.60.0100.00417.56
8.2.50.0120.00217.84
8.2.40.0090.00418.92
8.2.30.0110.00317.70
8.2.20.0080.00417.75
8.2.10.0080.00518.49
8.2.00.0100.00618.35
8.1.320.0090.00516.31
8.1.310.0130.00816.08
8.1.300.0150.00416.07
8.1.290.0090.00623.49
8.1.280.0120.00820.87
8.1.270.0220.00720.59
8.1.260.0130.00821.92
8.1.250.0100.00522.67
8.1.240.0180.00520.53
8.1.230.0130.00519.05
8.1.220.0170.00618.43
8.1.210.0130.00818.04
8.1.200.0190.00417.33
8.1.190.0190.00717.17
8.1.180.0120.00717.64
8.1.170.0120.00717.90
8.1.160.0200.00318.08
8.1.150.0170.00418.11
8.1.140.0160.00818.15
8.1.130.0160.00818.66
8.1.120.0170.00817.35
8.1.110.0180.00617.33
8.1.100.0080.00717.48
8.1.90.0070.00917.33
8.1.80.0090.00417.36
8.1.70.0100.00317.38
8.1.60.0120.00517.42
8.1.50.0150.00717.33
8.1.40.0130.00518.23
8.1.30.0130.00517.51
8.1.20.0180.00917.47
8.1.10.0070.00917.39
8.1.00.0140.00417.12
8.0.300.0090.00417.67
8.0.290.0110.00216.64
8.0.280.0150.00117.35
8.0.270.0060.00617.13
8.0.260.0120.00517.46
8.0.250.0140.00317.67
8.0.240.0110.00616.77
8.0.230.0140.00716.87
8.0.220.0190.00416.51
8.0.210.0140.00816.84
8.0.200.0150.00616.77
8.0.190.0110.00616.82
8.0.180.0100.00816.82
8.0.170.0110.00616.79
8.0.160.0110.00716.65
8.0.150.0130.00716.76
8.0.140.0170.00716.57
8.0.130.0140.00914.92
8.0.120.0130.00616.67
8.0.110.0120.00716.71
8.0.100.0120.00516.73
8.0.90.0130.00516.71
8.0.80.0100.00817.42
8.0.70.0120.00716.60
8.0.60.0130.00116.65
8.0.50.0150.00316.58
8.0.30.0160.01116.87
8.0.20.0150.00516.74
8.0.10.0090.00316.89
8.0.00.0160.01016.75
7.4.330.0130.00216.76
7.4.320.0140.00616.44
7.4.300.0070.00416.37
7.4.290.0100.00516.44
7.4.280.0150.00816.39
7.4.270.0150.00316.31
7.4.260.0160.00514.86
7.4.250.0110.00716.44
7.4.240.0120.00416.52
7.4.230.0130.00616.39
7.4.220.0060.00516.47
7.4.210.0100.01016.50
7.4.200.0110.00916.41
7.4.190.0160.00516.29
7.4.180.0120.00316.00
7.4.160.0200.00316.23
7.4.150.0190.00016.22
7.4.140.0170.00616.26
7.4.130.0170.01016.19
7.4.120.0180.00416.35
7.4.110.0160.01016.37
7.4.100.0180.00616.23
7.4.90.0170.00816.37
7.4.80.0180.00916.31
7.4.70.0170.00916.29
7.4.60.0170.00716.34
7.4.50.0200.01017.32
7.4.40.0190.00916.25
7.4.30.0260.00716.42
7.4.20.0150.00917.16
7.4.10.0180.01016.41
7.4.00.0200.00816.53
7.3.330.0170.00816.99
7.3.320.0110.00514.77
7.3.310.0100.00316.32
7.3.300.0090.00316.32
7.3.290.0120.01216.29
7.3.280.0270.01016.27
7.3.270.0240.00616.16
7.3.260.0210.00516.38
7.3.250.0180.01016.20
7.3.240.0170.00416.17
7.3.230.0120.00416.41
7.3.220.0120.00816.13
7.3.210.0120.00716.42
7.3.200.0120.00616.28
7.3.190.0150.00716.36
7.3.180.0150.00716.22
7.3.170.0160.01217.14
7.3.160.0130.00616.16
7.3.150.0160.00816.24
7.3.140.0100.00716.33
7.3.130.0130.00516.33
7.3.120.0180.00616.24
7.3.110.0190.00716.18
7.3.100.0200.00916.21
7.3.90.0220.00716.30
7.3.80.0160.00816.22
7.3.70.0100.00817.07
7.3.60.0170.00616.45
7.3.50.0110.00816.22
7.3.40.0130.00616.26
7.3.30.0150.00716.22
7.3.20.0100.00817.26
7.3.10.0120.00417.29
7.3.00.0200.00417.23

preferences:
30.46 ms | 403 KiB | 5 Q