Вывод определенного кол-ва слов


/ Published in: PHP
Save to your folder(s)

/**
* Функция выводит указанае кол-во слов
*
* @param int $count количество слов которое надо вывести
* @param string $str текст
*/


Copy this code and paste it in your HTML
  1. function CountWord ($count, $str)
  2. {
  3.  
  4. $articles = explode(' ', $str);
  5.  
  6. for ($i = 0; $i <= $count; $i++)
  7. {
  8. $text .= $articles[$i].' ';
  9.  
  10. }
  11.  
  12. return $text;
  13. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.