PHP Questions Home | Register | Login
Categories
Arrays
Files
Forms
Creating PDFs
PHP Errors
Functions
Images
MySQL
Numbers
Others
Strings
Website
Unanswered

PHP Forums
Forums Index
MySQL Forum
PHP Forum
Flash/Actionscript
Javascript
Web design

More PHP
PHP Functions
Top Questions
Ask a Question
PHP Interview Questions
PHP Jobs
Ecommerce
IT Questions
Business Websites

Sponsors

sponsor ad
My Salary
PHP Developer Salary
Advertise Here

How do I find the length of a string in PHP?


An extremely common thing to want to do in PHP is to find the length of a string. This may be for a variety of reasons, such as ensuring that the user has entered data of a sensible length into a form field (e.g. if their name is one letter long then there is probably something weird going on).

Here is a simple example of how this works:

<?php

$data 
"hello world";
echo 
strlen($data); //11
?>


And that's all there is to it - simple but very well worth knowing because it is something that you'll need to know time and time again.



Comment on this Question and Answer >>>

ASK A QUESTION

More strings PHP Questions

How do I count how many times each character occurs in a string?

How do I extract the values of variables from a string?

How do I one-way encrypt a string in PHP?

How can I remove spaces from around a string value?

How do I remove trailing whitespace from a string?



Custom Search