Trim and strlen function
After studying the variables, we continued the discussion of the trim and strlen function. The second function is used to manipulate the string.
- Trim (); used to remove the spaces on the right or left a text, examples of program code is as follows:
< ? php
$text=" test trim ";
$text=trim($text);
echo $text.$text;
?>
Output:
test trimtest trim
- Strlen(); used to calculate the text length, examples of program code is as follows:
< ? php
$text1=" test trim ";
$text2=trim($text1);
$lentext1=" Text1 Length = ".strlen($text1);
$lentext1=" Text2 Length = ".strlen($text2);
echo $lentext2."
";
echo $lentext1;
?>
Output:
Text1 Length = 11
Text2 Length = 9
Currently have 0 komentar: