
Let us start with initializing a string :
<?php $firststring="The quick brown fox"; $secondstring=" jumped over the lazy dog."; //Assigning one string to another $thirdstring = $firststring; $thirdstring .= $secondstring; echo $thirdstring; ?>Here is a list of certain methods that may come handy while manipulating strings :
Lowercase : <?php echo strtolower($thirdstring); ?> Uppercase : <?php echo strtoupper($thirdstring); ?> Uppercase first letter : <?php echo ucfirst($thirdstring); ?> Uppercase words : <?php echo ucwords($thirdstring); ?> Length : <?php echo strlen($thirdstring); ?> Trim : <?php echo $fourthstring=$firststring . trim($secondstring); ?> Find : <?php echo strstr($thirdstring,"brown"); ?> Replace by String : <?php echo str_replace("quick","so quick",$thirdstring); ?>
0 comments:
Post a Comment
Note: only a member of this blog may post a comment.