3v4l.org

run code in 300+ PHP versions simultaneously
<?php function generateKeywordsFromText($text){ // List of words NOT to be included in keywords $stopWords = array('à','à demi','à peine','à peu près','absolument','actuellement','ainsi','alors','apparemment','approximativement','après','après-demain','assez','assurément','au','aucun','aucunement','aucuns','aujourd\'hui','auparavant','aussi','aussitôt','autant','autre','autrefois','autrement','avant','avant-hier','avec','avoir','beaucoup','bien','bientôt','bon','c\'','ça','car','carrément','ce','cela','cependant','certainement','certes','ces','ceux','chaque','ci','comme','comment','complètement','d\'','d\'abord','dans','davantage','de','début','dedans','dehors','déjà','demain','depuis','derechef','des','désormais','deux','devrait','diablement','divinement','doit','donc','dorénavant','dos','droite','drôlement','du','elle','elles','en','en vérité','encore','enfin','ensuite','entièrement','entre-temps','environ','essai','est','et','étaient','état','été','étions','être','eu','extrêmement','fait','faites','fois','font','force','grandement','guère','habituellement','haut','hier','hors','ici','il','ils','infiniment','insuffisamment','jadis','jamais','je','joliment','ka','la','là','le','les','leur','leurs','lol','longtemps','lors','ma','maintenant','mais','mdr','même','mes','moins','mon','mot','naguère','ne','ni','nommés','non','notre','nous','nouveaux','nullement','ou','où','oui','par','parce','parfois','parole','pas','pas mal','passablement','personne','personnes','peu','peut','peut-être','pièce','plupart','plus','plutôt','point','pour','pourquoi','précisément','premièrement','presque','probablement','prou','puis','quand','quasi','quasiment','que','quel','quelle','quelles','quelque','quelquefois','quels','qui','quoi','quotidiennement','rien','rudement','s\'','sa','sans','sans doute','ses','seulement','si','sien','sitôt','soit','son','sont','soudain','sous','souvent','soyez','subitement','suffisamment','sur','t\'','ta','tandis','tant','tantôt','tard','tellement','tellement','tels','terriblement','tes','ton','tôt','totalement','toujours','tous','tout','tout à fait','toutefois','très','trop','tu','un','une','valeur','vers','voie','voient','volontiers','vont','votre','vous','vraiment','vraisemblablement'); //Let us do some basic clean up! on the text before getting to real keyword generation work $text = preg_replace('/\s{2,}/ui', '', $text); // replace multiple spaces etc. in the text $text = trim($text); // trim any extra spaces at start or end of the text $text = preg_replace('/[^\p{L}0-9 .-]+/u', '', $text); // only take alphanumerical characters, but keep the spaces and dashes too… $text = strtolower($text); // Make the text lowercase so that output is in lowercase and whole operation is case in sensitive. // Find all words preg_match_all('/\w+/iu', $text, $allTheWords); $allTheWords = $allTheWords[0]; //Now loop through the whole list and remove smaller or empty words foreach ( $allTheWords as $key=>$item ) { if ( $item == '' || in_array(strtolower($item), $stopWords) || strlen($item) <= 3 ) { unset($allTheWords[$key]); } } // Create array that will later have its index as keyword and value as keyword count. $wordCountArr = array(); // Now populate this array with keywrds and the occurance count if ( is_array($allTheWords) ) { foreach ( $allTheWords as $key => $val ) { $val = strtolower($val); if ( isset($wordCountArr[$val]) ) { $wordCountArr[$val]++; } else { $wordCountArr[$val] = 1; } } } // Sort array by the number of repetitions arsort($wordCountArr); //Keep first 10 keywords, throw other keywords $wordCountArr = array_slice($wordCountArr, 0, 10); // Now generate comma separated list from the array $words=""; foreach ($wordCountArr as $key=>$value) $words .= " " . $key ; // Trim list of comma separated keyword list and return the list return trim($words," "); } echo $contentkeywords = generateKeywordsFromText("Hello Héllo");

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.140.0130.00817.96
8.4.130.0090.01118.20
8.4.120.0140.00720.65
8.4.110.0120.00723.96
8.4.100.0060.00618.15
8.4.90.0120.00920.75
8.4.80.0090.00718.11
8.4.70.0060.00418.29
8.4.60.0120.00920.67
8.4.50.0100.00719.73
8.4.40.0060.00318.18
8.4.30.0030.00620.48
8.4.20.0030.01618.97
8.4.10.0040.00420.83
8.3.270.0110.00916.98
8.3.260.0110.00916.77
8.3.250.0100.00818.80
8.3.240.0150.00516.77
8.3.230.0080.00717.04
8.3.220.0040.00319.21
8.3.210.0090.01017.11
8.3.200.0040.00516.82
8.3.190.0110.00717.55
8.3.180.0140.00616.99
8.3.170.0140.00317.39
8.3.160.0060.00918.85
8.3.150.0100.01020.76
8.3.140.0060.00317.08
8.3.130.0040.00418.90
8.3.120.0040.00421.03
8.3.110.0080.00020.94
8.3.100.0040.00824.06
8.3.90.0040.00426.77
8.3.80.0070.00019.36
8.3.70.0140.00717.00
8.3.60.0170.00318.75
8.3.50.0110.00723.80
8.3.40.0140.00718.95
8.3.30.0140.00418.98
8.3.20.0080.00024.18
8.3.10.0000.00824.66
8.3.00.0040.00426.16
8.2.290.0110.00916.88
8.2.280.0040.00618.84
8.2.270.0110.00717.33
8.2.260.0090.00918.86
8.2.250.0040.00418.67
8.2.240.0090.00619.19
8.2.230.0160.00322.58
8.2.220.0060.00337.54
8.2.210.0000.00826.77
8.2.200.0000.01218.88
8.2.190.0110.01117.00
8.2.180.0180.00325.92
8.2.170.0040.01119.20
8.2.160.0030.01022.96
8.2.150.0050.00225.66
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0090.00020.87
8.2.110.0060.00320.58
8.2.100.0070.01018.09
8.2.90.0000.00820.42
8.2.80.0030.00620.50
8.2.70.0080.00017.88
8.2.60.0040.00417.75
8.2.50.0090.00018.10
8.2.40.0000.00819.54
8.2.30.0060.00319.47
8.2.20.0030.00518.23
8.2.10.0070.00419.54
8.2.00.0040.00419.31
8.1.330.0120.00816.48
8.1.320.0150.00616.31
8.1.310.0120.00618.65
8.1.300.0000.01920.23
8.1.290.0060.00330.84
8.1.280.0120.00925.92
8.1.270.0050.00323.99
8.1.260.0090.00926.35
8.1.250.0050.00328.09
8.1.240.0120.00922.25
8.1.230.0110.00023.86
8.1.220.0040.00417.79
8.1.210.0040.00419.10
8.1.200.0000.00817.60
8.1.190.0000.00817.61
8.1.180.0000.01018.10
8.1.170.0030.00518.89
8.1.160.0040.00419.14
8.1.150.0050.00319.11
8.1.140.0000.00818.93
8.1.130.0040.00420.25
8.1.120.0080.00017.70
8.1.110.0000.00917.60
8.1.100.0060.00317.69
8.1.90.0050.00317.56
8.1.80.0080.00017.63
8.1.70.0030.00317.57
8.1.60.0030.00617.76
8.1.50.0020.00517.72
8.1.40.0030.00517.59
8.1.30.0000.00817.80
8.1.20.0090.00617.78
8.1.10.0130.00517.77
8.1.00.0120.00517.66
8.0.300.0070.00020.21
8.0.290.0030.00517.13
8.0.280.0050.00318.45
8.0.270.0040.00417.09
8.0.260.0040.00418.46
8.0.250.0000.00817.30
8.0.240.0050.00217.25
8.0.230.0030.00317.20
8.0.220.0000.00717.16
8.0.210.0040.00417.16
8.0.200.0030.00317.09
8.0.190.0040.00417.20
8.0.180.0070.00017.19
8.0.170.0030.00617.14
8.0.160.0000.00717.04
8.0.150.0090.00516.97
8.0.140.0060.00817.08
8.0.130.0120.00215.31
8.0.120.0060.00717.14
8.0.110.0100.00317.10
8.0.100.0070.00717.11
8.0.90.0080.00417.11
8.0.80.0110.00817.19
8.0.70.0030.01017.12
8.0.60.0080.00717.19
8.0.50.0110.00217.14
8.0.30.0100.00717.25
8.0.20.0120.00617.28
8.0.10.0070.00617.05
8.0.00.0150.00917.05
7.4.330.0000.00515.55
7.4.320.0070.00016.81
7.4.300.0000.00816.82
7.4.290.0030.00316.89
7.4.280.0030.00516.80
7.4.270.0090.00516.87
7.4.260.0070.00415.22
7.4.250.0080.00816.88
7.4.240.0120.00016.90
7.4.230.0120.00316.79
7.4.220.0060.00416.82
7.4.210.0120.00716.85
7.4.200.0070.00716.76
7.4.190.0130.00716.74
7.4.180.0170.00416.83
7.4.160.0160.00316.63
7.4.150.0150.00316.72
7.4.140.0150.00316.59
7.4.130.0110.00616.82
7.4.120.0140.00416.77
7.4.110.0100.00616.61
7.4.100.0090.00616.69
7.4.90.0080.00916.67
7.4.80.0140.00616.72
7.4.70.0080.01016.83
7.4.60.0100.00816.75
7.4.50.0090.00816.65
7.4.40.0100.00916.76
7.4.30.0130.00716.72
7.4.20.0120.00616.74
7.4.10.0070.01016.64
7.4.00.0110.00816.59
7.3.330.0070.00616.65
7.3.320.0080.00415.11
7.3.310.0100.00416.59
7.3.300.0070.00716.54
7.3.290.0100.00916.55
7.3.280.0110.00716.63
7.3.270.0170.00616.60
7.3.260.0110.00716.77
7.3.250.0170.00316.58
7.3.240.0170.00316.58
7.3.230.0120.00616.58
7.3.220.0190.00016.55
7.3.210.0100.01116.66
7.3.200.0110.01016.66
7.3.190.0150.00716.56
7.3.180.0130.00616.68
7.3.170.0150.00416.69
7.3.160.0120.00716.56
7.3.150.0100.00816.70
7.3.140.0120.00916.61
7.3.130.0140.00816.66
7.3.120.0090.01016.62
7.3.110.0130.00616.61
7.3.100.0110.00816.56
7.3.90.0110.00716.80
7.3.80.0110.00816.53
7.3.70.0110.01016.64
7.3.60.0090.01016.64
7.3.50.0130.00716.73
7.3.40.0110.00616.63
7.3.30.0170.01416.66
7.3.20.0120.01117.26
7.3.10.0130.00817.18
7.3.00.0140.00717.31
7.2.340.0160.00316.77
7.2.330.0130.00716.91
7.2.320.0140.00616.80
7.2.310.0110.01016.87
7.2.300.0100.01216.66
7.2.290.0100.00816.88
7.2.280.0130.00716.76
7.2.270.0130.00916.89
7.2.260.0130.00816.78
7.2.250.0110.00816.81
7.2.240.0070.01116.84
7.2.230.0140.00716.81
7.2.220.0100.01116.89
7.2.210.0100.00916.78
7.2.200.0100.01016.86
7.2.190.0160.00216.85
7.2.180.0100.01116.82
7.2.170.0100.00816.87
7.2.160.0140.00716.90
7.2.150.0280.01117.46
7.2.140.0140.00817.61
7.2.130.0120.01017.53
7.2.120.0160.00717.53
7.2.110.0140.00917.56
7.2.100.0160.00617.44
7.2.90.0110.00817.56
7.2.80.0120.00917.55
7.2.70.0120.01017.52
7.2.60.0150.00817.57
7.2.50.0150.00617.51
7.2.40.0160.00517.55
7.2.30.0110.01117.56
7.2.20.0080.01217.53
7.2.10.0120.00717.46
7.2.00.0110.01017.60

preferences:
34.84 ms | 403 KiB | 5 Q