Answer the question
In order to leave comments, you need to log in
How to correctly count the number of characters here?
Hello! There was a task, to count up in a piece of the text how many characters there. I found the required variable, tested it at the test site, everything works as it should!
$str = 101;
$strTotal = strlen($str);
echo "$strTotal";
3
%file_description%
$strTotal = strlen(%file_description%);
echo "$strTotal";
%file_description%
? Answer the question
In order to leave comments, you need to log in
There may be problems with counting Cyrillic characters, use mb_strlen()
How bad is your knowledge... %file_description% is not a php variable and not a variable at all, and you can't use it in php functions.
%file_description%
- not a variable. All php variables start with $. Most likely, this variable must first be replaced with some value.
$file_description = "Hello World";
$str = "abc %file_description% def";
$str = str_ireplace("%file_description%", $file_description, $str); // Заменяет %file_description% на значение переменной $file_description
$strTotal = strlen($str);
echo "$strTotal";
// abc(3) + def(3) + " "(1) + " "(1) + Hello(5) + World(5) + " "(1) = 19
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question