[ create a new paste ] login | about

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

PHP, pasted on Aug 30:
<?php

	$string = "Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision. But when I try to look at you, you scurry away. Are you shy, squiggly line? Why only when I ignore you, do you return to the center of my eye? Oh, squiggly line, it's alright, you are forgiven.";

	echo wordlimit($string, 20);
	
	function wordlimit($string, $limit) {
		
		$overflow = true;
		
		$array = explode(" ", $string);
		
		$output = '';
		
		for ($i = 0; $i < $limit; $i++) {
			
			if (isset($array[$i])) {
				
				$output .= $array[$i] . " ";
			}
			else {
				
				$overflow = false;
			}
		}
		
		return trim($output) . ($overflow === true ? "..." : '');
	}
	
?>


Output:
1
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision. But when...


Create a new paste based on this one


Comments: