It returns the position of the first occurrence of a string inside another string
Example
<?php
echo stripos(“phpcode”,”code”);
?>
Output
3
It returns the position of the first occurrence of a string inside another string
Example
<?php
echo stripos(“phpcode”,”code”);
?>
Output
3
It removes backslashes added by the addcslashes() function
Example
<?php
echo stripcslashes(“phpcode”);
?>
Output
phpcode
It strips HTML and PHP tags from a string
Example
<?php
echo strip_tags(“<div><p>phpcode</p></div>”);
?>
Output
phpcode
It returns the number of characters found in a string before any part of the specified characters are found.
Example
<?php
echo strcspn(“phpcode”,”c”);
?>
Output
3
It compares two strings based on locale setting
Example
<?php
echo strcoll(“phpcode”, “PHPCode”);
?>
Output
1
It compares two strings
Example
<?php
if (strcmp(“phpcode”, “PHPCode”) == 0) {
echo ‘Strings are equal’;
}else{
echo ‘Strings are not equal’;
}
?>
Output
Strings are not equal
Its an alias of strstr() and find the first occurrence of a string
Example
<?php
echo strchr(‘info@phpcodez.com’, ‘@’, true);
?>
Output
info
It compares two strings (case-insensitive)
Example
<?php
if (strcasecmp(“phpcode”, “PHPCode”) == 0) {
echo ‘Strings are equal’;
}
?>
Output
Strings are equal
It return the number of words in a string
Example
<?php
echo “<pre>”;
print_r(str_word_count(‘It return the number of words in a string’));
?>
Output
9
It convert a string to an array
Example
<?php
echo “<pre>”;
print_r(str_split(‘phpcode’,2));
?>
Output
Array
(
[0] => ph
[1] => pc
[2] => od
[3] => e
)