Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ambil ringkasan berdasarkan jumlah kata (default 100 kata pertama)
- function ringkasan($text,$len=100){
- $text = strip_tags(trim($text));
- $text = str_replace(array(" "," ")," ",$text);
- $text = trim(str_replace(" "," ",$text));
- $eText = explode(" ",$text);
- $nText = count($eText);
- $output = "";
- if($nText>$len){
- for($i=0;$i<=$len;$i++)$output[] = $eText[$i];
- $output = implode(" ",$output)."...";
- }else{
- $output = $text;
- }
- $output = trim($output);
- return $output;
- }
- // ambil hanya beberapa karakter (default 100 karakter pertama)
- function potongText($text,$len=100){
- $text = strip_tags(trim($text));
- $text = str_replace(array(" "," ")," ",$text);
- $text = trim(str_replace(" "," ",$text));
- $nText = strlen($text);
- if($nText>$len){
- $output = substr(0,$len,$text)."...";
- }else{
- $output = $text;
- }
- return $output;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement