[ create a new paste ] login | about

Link: http://codepad.org/6JfSbhlF    [ raw code | output | fork ]

PHP, pasted on Feb 17:
<?php
//$_fp = fopen("php://stdin", "r");
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
$array = $vals = array();
//collecting words as an array
//while($in = fread($_fp,1024)){ 
$in = "omg lol you guys check thsi thread lmao! legit top lel right there bahah look at the guys face oh man lol ";
    $array = array_merge($array, explode(' ', $in));
	//}
$vals = array_count_values($array);
$lp = ['lol' => 1, 'rofl' => 2,'lmao' => 3, 'lel' => 4];
$allowed = ['lol' => true, 'rofl' => true,'lmao' => true, 'lel' => true];
$filtered = array_filter(
    $vals,
    function ($val, $key) use ($allowed) { // N.b. $val, $key not $key, $val
        return isset($allowed[$key]) && (
            $allowed[$key] === true || $allowed[$key] === $val
        );
    },
    ARRAY_FILTER_USE_BOTH
);
$points = 0;
foreach($filtered as $keyword => $laughpoint) {
     $points += $lp[$keyword] * $vals[$keyword];
}
if($points<=5){
    print "Patient has bright red face";
}elseif($points>5 && $points<=12 ){
    print "Patient is unable to speak";
}elseif($points>12 && $points<=20){
    print "Patient's sides are mildly bruised";
}elseif($points>20 && $points<=31){
    print "Patient has broken jaw, fractured ribs";
}elseif($points>31 && $points<=49){
    print "Patient is in a coma";
}else{
    print "Patient is dead";
}


Output:
1
2

Parse error: syntax error, unexpected '[' on line 11


Create a new paste based on this one


Comments: