Posted by: Sourav | February 8, 2011

Some string functions


<html>
<head>
<title>
StringFunctions
</title>
</head>
<body>
<?php
$firststring=”The quick brown fox”;
$secondstring=” jumped over the lazy dog.”;
?>
<?php
$thirdstring=$firststring;
$thirdstring.=$secondstring;
echo $thirdstring;
?>
<br />
Lowercase:<?php echo strtolower($thirdstring); ?><br />
Uppercase:<?php echo strtoupper($thirdstring); ?><br />
Uppercase First Letter:<?php echo ucfirst($thirdstring); ?><br />
Uppercase Words:<?php echo ucwords($thirdstring); ?><br />
<br />
Length:<?php echo strlen($thirdstring); ?><br />
Trim:<?php echo $fourthstring=$firststring.trim($secondstring); ?><br />
Find:<?php echo strstr($thirdstring,”brown”); ?><br />
Replace by string<?php echo str_replace(“quick”,”super fast”,$thirdstring); ?><br />
<br />
</body>
</html>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: