For example,
<html>
<head>
<title > Learn Php</title>
</head>
<body>
<?php
$str=" I am a Student ";
echo '<p>'.'"We have String $str=" I am a Student "'.'</p>';
echo '<p>'."Before Trim:".$str,"Mr. Steav";
echo '<p>'."After Trim:".trim($str),"Mr.Steav";
?>
</body>
</html>
Moreover, we can remove any characters from starting and ending from string-data by using function trim($str,$anycharacters). For Example, When you want to get any string value without any character at starting and ending of it.
please below:
<html>
<head>
<title > Learn Php</title>
</head>
<body>
<?php
$str="I am a m I Student m";
echo '<p>'.'When You Want to remove "I am" from "$str"'.'</p>';
echo '<p>'.'Before trim:'.$str."at RUPP".'</p>';
echo '<p>'.'After trim:'.trim($str,"I am")."at RUPP".'</p>';
?>
</body>
</html>
In example above function trim will remove any character such as (I,space,a,m) from starting and ending of $str.
Please see result:
No comments:
Post a Comment