[ create a new paste ] login | about

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

PHP, pasted on Mar 26:
1
2
3
4
5
6
7
8
<?php
function getFirstXWord($string, $a) {
	$temp = explode(" ", $string);
	return implode(" ", array_slice($temp, 0, $a, true));	
}

echo getFirstXWord("this is a content but do not trust this content", 5);
?>


Output:
1
this is a content but


Create a new paste based on this one


Comments: