3v4l.org

run code in 300+ PHP versions simultaneously
<?php function isSpam($comment) { // Pattern to match common phrases and links $pattern = '/(Like or Not\?|Check:)\s*(https?:\/\/[^\s]+)/i'; // Check if the pattern matches if (preg_match($pattern, $comment)) { return true; } // Known spam phrases (can be expanded) $knownSpam = [ "Like or Not? Check:", ]; // Calculate similarity with known spam phrases foreach ($knownSpam as $spam) { if (similar_text($spam, substr($comment, 0, strlen($spam))) / strlen($spam) > 0.8) { return true; } } return false; } echo isSpam('like or not');
Output for 8.1.0 - 8.1.29, 8.2.0 - 8.2.21, 8.3.0 - 8.3.9

preferences:
92.14 ms | 403 KiB | 67 Q