[ create a new paste ] login | about

Link: http://codepad.org/1H2tZJr3    [ raw code | fork ]

PHP, pasted on Jan 5:
<?php

//string string of invalid chars and make it lowercase
$string = "This is the best sentence ever! Winning!";
$string = strtolower($string);
$string = preg_replace('/[^\w\d_ -]/si', '', $string);



$lines = explode("\n", file_get_contents("wordlist.txt"));
$words = explode(" ", $string);
foreach ($lines as $line) {
    $split = preg_split("/(\#|\t)/", $line); //split on # or tab
    $words[$split[0]] = array_pop($split);
    //split[0] (first element) contains the word
    //array_pop (last element) contains score
	
	echo array_pop($split);
}

//do whatever
echo $words["best"] + $words["inlaid"] + $words["laziness"];
?>


Create a new paste based on this one


Comments: