3

How to find number of characters in a string in PHP

 2 years ago
source link: https://www.laravelcode.com/post/how-to-find-number-of-characters-in-a-string-in-php
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

How to find number of characters in a string in PHP

  1205 views

  2 years ago

PHP

Use the PHP strlen() function

You can simply use the PHP strlen() function to find the number of characters in a string of text. It also includes the white spaces inside the specified string.

Let's take a look at the following example to understand how it basically works:

<?php
$my_str1 = 'The quick brown fox jumps over the lazy dog.';
echo strlen($my_str1); // Outputs: 44
 
$my_str2 = '    The quick brown fox jumps over the lazy dog. ';
echo strlen($my_str2); // Outputs: 49
?>
Author : Harsukh Makwana
Harsukh Makwana

Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK