PHP | count_chars() Function

PHP count_chars() Function


Hello folks! welcome back to a new edition of our tutorial on PHP. In this tutorial guide, we are going to be studying about the PHP count_chars() Function.

The PHP count_chars() function returns the information about characters that are used in a string.

Syntax

Following below is the syntax to use this function -

mixed count_chars ( string $string [, int $mode = 0 ] )


Parameter Details

Sr.NoParameters & Description
1

string

it examined string.

2

mode

it returns the mode


Return Value

Depending on mode the PHP count_chars() function returns one of the following -

  • 0 - an array with the byte-value as key and the frequency of every byte as value.
  • 1 - same as 0 but only byte-values with a frequency greater than zero are listed.
  • 2 - same as 0 but only byte-values with a frequency equal to zero are listed.
  • 3 - a string which contains all the unique characters is returned.
  • 4 - a string which contains all the unused characters is returned

Alright guys! This is where we are going to be rounding up for this tutorial post. In our next tutorial, we will be studying about the PHP crc32() Function.

Feel free to ask your questions where necessary and we will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.

Follow us on our various social media platforms to stay updated with our latest tutorials. You can also subscribe to our newsletter in order to get our tutorials delivered directly to your emails.

Thanks for reading and bye for now.