Working with text - Jet\Data_Text

There are several methods for working with text that are used by the Jet platform, but of course can be useful in the application space as well.

Method Overview

Method Meaning of
public static removeAccents(
string $text
) : string
Removes all diacritics from the text. This means that it converts characters like čšťď to cstd.
public static replaceData(
string $text,
array $data
) : string
Replaces the keys in the text with values from the array. Let's see an example: $text 'Your name is %user_name% and your role is %user_role%.';
$data = [
'user_name' => 'Jára Cimrman',
'user_role' => 'Administrator'

$result Data_Text::replaceData($text$data);

//value of $result: 'Your name is Jára Cimrman and your role is Administrator'

This method is used, for example, by the translator
public static htmlSpecialChars(
string $input,
bool $encode_quotes=false
) : string
It takes care of encoding potentially dangerous data before displaying it in HTML.
Previous chapter
Next chapter
Working with a tree structure - Jet\Data_Tree