3v4l.org

run code in 300+ PHP versions simultaneously
<?php class keywords { public $ngramsSpecific = array ( 'tos pačios lyties', 'seksualin* mažum*', 'gėj* eityn*' ); public $ngramsGeneric = array ( 'žmogaus teis*' ); public $keywordsSpecific = array ( 'gėjus', 'lesbietė', 'transvestitas', 'homoseksualas', 'biseksualas', 'homoseksualumas', 'homoseksualus', 'pride', 'LGBT', 'homofobija', 'homofobiškas', 'transseksualas', 'LGBTQ', 'DOMA', 'queer' ); public $keywordsGeneric = array ( 'tolerantiškas', 'tolerancija', 'diskriminacija', 'orientacija', 'paradas', 'eitynės', 'neapykanta', 'lygybė', 'mažuma' ); public $positiveAuthors = array ( 'Nida Vasiliauskaitė', 'Artūras Rudomanskis', 'Marija Aušrinė Pavilionienė', 'Mindaugas Kluonis', 'J. V. Daugmaudis' ); public $negativeAuthors = array ( 'Liudvika Pociūnienė', 'Tomas Čyvas', 'Vytautas Sinica', 'Paulius Stonis' ); } function getRelevancy(article $article = null) { $keywords = new keywords(); //$articleBody = strtolower($article->body); $articleBody = "laba diena seksualinė mažuma yra labai geri, bet seksualinės mažumos nėra pats geriausias vaistas nuo visu ligu, nes seksualinėse mažumose gali buti pasitaike daugybe ivairiu dalyku tuo tarpu aseseksualinės mažumos nenori valgyto"; $match = array(); foreach($keywords->ngramsSpecific as $ngram) { //\b(seksualin\w+)\s\b(mazum\w+) $ngram = str_ireplace('*', '\w+', $ngram); $exploded = explode(" ", $ngram); foreach($exploded as &$piece) { $piece = "\b" . $piece; } $regex = "/" . implode("\s", $exploded) . "/iu"; preg_match_all($regex, $articleBody, $matches); $match[] = $matches; } return $match; /* $annotatedTitle = annotateText($article->title); $annotatedBody = annotateText($article->body); $titleIntersection = array_intersect($annotatedTitle, array_map('strtolower', $specificKeywords)); $bodyIntersection = array_intersect($annotatedBody, array_map('strtolower', $specificKeywords)); $titleIntersectionI = array_intersect($annotatedTitle, array_map('strtolower', $genericKeywords)); $bodyIntersectionI = array_intersect($annotatedBody, array_map('strtolower', $genericKeywords)); return array($titleIntersection, $bodyIntersection, $titleIntersectionI, $bodyIntersectionI); */ } print_r(getRelevancy());
Output for 5.3.4 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.35, 5.6.0 - 5.6.21, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.5 - 7.2.33, 7.3.12 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Array ( [0] => Array ( [0] => Array ( ) ) [1] => Array ( [0] => Array ( [0] => seksualinė mažuma [1] => seksualinės mažumos [2] => seksualinėse mažumose ) ) [2] => Array ( [0] => Array ( ) ) )
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.3
Array ( [0] => Array ( [0] => Array ( ) ) [1] => Array ( [0] => Array ( ) ) [2] => Array ( [0] => Array ( ) ) )
Output for 5.0.0 - 5.0.5
Fatal error: Argument 1 must not be null in /in/qNd6N on line 31
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/qNd6N on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/qNd6N on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/qNd6N on line 4
Process exited with code 255.

preferences:
223.64 ms | 401 KiB | 342 Q