Created
February 16, 2019 21:01
-
-
Save CB9TOIIIA/b0ebefb985c3658885c67b47e6f32df4 to your computer and use it in GitHub Desktop.
Ограничение количества вводимых символов
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$desc = JString::trim(strip_tags($this->renderPosition('<ИМЯ ПОЗИЦИИ В ШАБЛОНЕ>'))); | |
$descArr = explode(' ', $desc); | |
$descArr_tmp = array(); | |
foreach ($descArr as $word) { | |
$word = JString::trim($word); | |
if ($word) { | |
$descArr_tmp[] = $word; | |
} | |
} | |
if (count($descArr_tmp) > 40) { | |
$descArr_tmp = array_slice($descArr_tmp, 0, 40); // 40 - это кол-во слов | |
echo implode(' ', $descArr_tmp). ' ...'; | |
} else { | |
echo implode(' ', $descArr_tmp); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment