<?php // Keyword:Point $keywords = [ 'lol' => 1, 'rofl' => 2, 'lmao' => 3, 'lel' => 4 ]; $text = "omg lol you guys check thsi thread lmao! legit top lel right there bahah look at the guys face oh man lol "; $words = array_count_values(explode(' ', $text)); $points = 0; foreach ($keywords as $keyword => $point) { if (isset($words[$keyword])) $points += $point * $words[$keyword]; } echo $points;
Обсуждают сегодня