Runing Text

Do not Click

Trim and strlen function

Wednesday 20 January 2010 , Posted by Andi at 09:44

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:

Leave a Reply

Post a Comment

Related Post