- Forums
- PHP
- Learn How To Count How Many Characters A String Has In PHP Tutorial PHP
This Page Contains information about Learn How To Count How Many Characters A String Has In PHP Tutorial PHP By wallpaperama in category PHP with 1 Replies. [1007], Last Updated: Sat May 18, 2024
wallpaperama
Tue Feb 06, 2007
1 Comments
1262 Visits
with PHP you can do many things, if you have a string, you can determine how many character or letters a string has with the strlen() function. I have created this tutorial to help anyone who is confused on how you can find out how many characters are in a string or a database field.
The only requirement is that you have php, if you don't have php on you website, you can sign up with our friends at ww.webune.com, they can hook you up with some web hosting, if you have a large site, i recommend you get their dedicated hosting, i am very happy with their service and support.
so, to show you the strlen() in action copy and past this code and save it as string-length.php and upload to your php website and open it with your browser. you can use notepad in if you have windows or you can use any of your favorite text editor. i use notepad cuz its easy.
so here is the code:
CODE:
<style type="text/css">
<!--
.style1 {
color: #006600;
font-weight: bold;
padding: 3px;
border: 1px solid #CCCCCC;
}
.style2 {
color: #CC3300;
font-weight: bold;
}
.style3 {color: #0033FF}
-->
</style>
<h1>Show How Many Character are in a string in PHP</h1><hr>
<p>by <a href="http://www.wallpaperama.com">wallpaperama.com</a>a</p>
<p>This is the value of my variable called $string: </p>
<p class="style1">I am writing this tutorial to show you how you can cut down on the words with php. if you need php web hosting, our friends at webune.com have the right solution for you. dedicated hosting is the best way to go if you have a large website. as you can see, this string is pretty long.</p>
<p>Now this is the output of <span class="style2"><span class="style3">echo</span> strlen($string)</span></p>
<p>NOTE: 0 is the start of the string and 100 is the end. so i am telling php that display the characters in the string starting at 0 and stop at the 100th character.</p>
<p> </p>
<p><?
$string ="I am writing this tutorial to show you how you can cut down on the words with php. if you need php web hosting, our friends at webune.com have the right solution for you. dedicated hosting is the best way to go if you have a large website. as you can see, this string is pretty long.";
echo "<span class=\"style3\"> \$string has a total of ".strlen($string)." characters</span>";
?>
</p>
<p>Dont forget to tell your friends about where they can find free amazing wallpapers, only at Wallpaperama!</p>
<p align="center">Script by <a href="http://www.wallpaperama.com">wallpaperama.com</a> </p>
<p align="center">PHP Hosting at <a href="http://www.webune.com">Webune.com </a></p>
that's it, save it and upload to your site, you will see how it works.
How many characters can a String hold?
how many characters after "." in a string
searching for a string that has many '/' characters
The name contains too many character
https://www.wallpaperama.com/forums/learn-how-to-count-how-many-characters-a-string-has-in-php-tutorial-php-t790.html