It translate characters or replace substrings
Example
<?php
echo strtr(“One Two”,array(“One” => “PHP”, “Two” => “HTML”));
?>
Output
PHP HTML
It translate characters or replace substrings
Example
<?php
echo strtr(“One Two”,array(“One” => “PHP”, “Two” => “HTML”));
?>
Output
PHP HTML
It makes a string uppercase
Example
<?php
echo strtoupper(“PHPCode”);
?>
Output
PHPCODE
It makes a string lowercase
Example
<?php
echo strtolower(“PHPCode”);
?>
Output
phpcode
It splits a string into smaller strings
Example
<?php
$tokenVal = strtok(“php html js”, ” “);
while ($tokenVal != false) {
echo $tokenVal .” “;
$tokenVal =strtok(” “);
}
?>
Output
php html js
It finds the first occurrence of a string
Example
<?php
echo strstr(“phpcode”,”co”);
?>
Output
code
It returns the number of characters found in the string that contains only characters from the charlist.
Example
<?php
echo strspn(“phpcodephp”,”phpe”);
?>
Output
3
It finds the position of the last occurrence of a substring in a string
Example
<?php
echo strrpos(“phpcodeccr”,”p”);
?>
Output
2
It find the position of the last occurrence of a substring in a string(case-insensitive)
Example
<?php
echo strripos(“phpcodeccr”,”c”);
?>
Output
8
It reverse a string
Example
<?php
echo strrev(“phpcodeccr”);
?>
Output
rccedocphp
It finds the last occurrence of a character in a string
Example
<?php
echo strrchr(“phpcodeccr”,”co”);
?>
Output
cr