PHP STRINGS
PHP offers a variety of string functions that allow you to manipulate and work with strings effectively.
strlen: Return the length of the string.
$Name=" Santhoshkumar";
$strlen=$Name;
//output 13
strpos: Returns the position of the first occurrence of a substring within a string
$string="string function";
echo strpos($string, function);
//output 7
str_replace: Replaces occurrences of a substring with another substring.
$string=" Hello Everyone";
echo str_replace("Everyone","guys","Hello Everyone ");
// output Hello guys
Strrev: You can reverse a string in PHP using the strrev() function.
$name="sujitha";
echo strrev($name);
//output ahtijus
Strcasecmp: Function in PHP is used to perform a case-insensitive string comparison. It returns 0 if the two strings are equal.
<?php
echo strcasecmp("santhosh", "SANTHOSH");
?>
// output 0
Strcspn: Function in PHP is used to find the length of the initial segment of a string.
<?php
echo strcspn("Hello Everyone","o");
?>
// output 5