{ // Create the empty word frequency array $freq = array(); // Split the parameter string into words $words = preg_split("/[ .,;:!?]\\s*/", $str); // Loop to count the words (either increment or initialize to 1) foreach ($words as $word) { $keys = array_keys($freq); if (in_array($word, $keys)) { $freq[$word]++; } else { $freq[$word] = 1; } } return $freq; } #** End of splitter // Main test driver $str = "apples are good for you, or don't you like apples?\n or maybe you like oranges better than apples"; // Call splitter $tbl = splitter($str); // Display the words and their frequencies print "<br /> Word Frequency <br /><br />"; $sorted_keys = array_keys($tbl); sort($sorted_keys); foreach ($sorted_keys as $word) { print "{$word} {$tbl[$word]} <br />"; } ?> </body> </html>
//de-dupe if (!in_array(splitter($timg->img), $testimage)) { array_push($newimg, $timg); array_push($testimage, splitter($timg->img)); } } } //get the background images $pattern = '/url\\(([^\\)]+)/i'; preg_match_all($pattern, $html, $out); $urls = $out[1]; foreach ($urls as $foo) { if (strpos($foo, '.') !== false && (strpos(strtolower($foo), '.jpg') !== false || strpos(strtolower($foo), '.png') !== false || strpos(strtolower($foo), '.gif') !== false || strpos(strtolower($foo), '.jpeg') !== false || strpos(strtolower($foo), '.bmp') !== false)) { $timg = new stdClass(); $timg->img = $foo; if (!in_array(splitter($timg->img), $testimage)) { array_push($newimg, $timg); } } } //get an array of image urls $imagebatch = array(); $count = 0; $i_url = array(); foreach ($newimg as $image) { $foo = new stdClass(); $foo->img = array(); array_push($foo->img, $image->img); if (isset($image->thumb)) { array_push($foo->img, $image->thumb); //youtube