mirror of
https://github.com/moodle/moodle.git
synced 2025-08-08 18:36:42 +02:00
MDL-46256 count_letters: an unit tests and fix HTML editity handling
This commit is contained in:
parent
c110115cc0
commit
82a050d67b
2 changed files with 27 additions and 1 deletions
|
@ -8375,11 +8375,12 @@ function count_words($string) {
|
|||
* Letters are defined as chars not in tags and different from whitespace.
|
||||
*
|
||||
* @category string
|
||||
* @param string $string The text to be searched for letters.
|
||||
* @param string $string The text to be searched for letters. May be HTML.
|
||||
* @return int The count of letters in the specified text.
|
||||
*/
|
||||
function count_letters($string) {
|
||||
$string = strip_tags($string); // Tags are out now.
|
||||
$string = html_entity_decode($string);
|
||||
$string = preg_replace('/[[:space:]]*/', '', $string); // Whitespace are out now.
|
||||
|
||||
return core_text::strlen($string);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue