String

PHP-String

PHP String function

1.strlen() function:-

The PHP strlen() function is used to find the length of a string.

Example

<?php
echo strlen("web pathshala");
?>

output

13

2.str_word_count() function:-

The PHP str_word_count() function is used to count the words in a string.

Example

<?php
echo str_word_count("web pathshala");
?>

output

2

3.strrev() function:-

The PHP strrev() function is used to reverse a string.

Example

<?php
echo strrev ("web pathshala");
?>

output

alahshtaP beW

4.strpos() function:-

The PHP strpos() function is used to searches for a specific text within a string.

Example

<?php
echo strpos("web pathshala","pathshala");
?>

output

4

5.str_replace() function:-

The PHP str_replace() function is used to replaces some characters with some other characters in a string

Example

<?php
echo str_replace("pathshala", "student", "Hello pathshala");
?>

output

Hello student