Tuesday, 15 October 2013

String Functions

How to find the length of string ?
strlen() function counts the number of characters including white spaces.
<?php
echo strlen("Hello world!"); // output : 12
?>

How to remove white space from the string?
trim() function removes white spaces from start and end of string.
<?php
$str = "Hello World!";
echo $str . "<br>";
echo trim($str," Hello"); // output : Hello 
?>   

No comments:

Post a Comment