<?php
/*
Definitions and usage
The Strstr () function searches for a string that appears for the first time in another string.
The function returns the remainder of the string (from a match point). returns false if the searched string is not found.
Grammar
String Strstr (string, search)
Parameter description
String required. Specify the string to be searched for.
Search required. Specify the string to search for. If the argument is a number, search for characters that match the numeric ASCII value
Tips and comments
Note: This function is binary safe.
Note: This function is sensitive to case sensitivity. For case insensitive searches, use STRISTR ().
If you just want to determine if needle exists in haystack, use the Strpos () function that is faster and consumes less memory.
*/
$str = ". The specified searched string ";
$s = "";
Echo strstr ($str, $s). "<br/>";
Echo Mb_strstr ($str, $s, ' utf-8 '). "<br/>";
Echo Mb_strstr ($str, $s, true, ' utf-8 '). "<br/>";
Echo Mb_strstr ($str, $s, false, ' utf-8 '). "
/*
Definitions and usage
The STRRCHR () function finds the last occurrence of a string in another string and returns all characters from that position to the end of the string.
Returns False if it fails.
Grammar
STRRCHR (String,char)
Parameter description
String required. Specify the string to be searched for.
Char required. Specify the characters to find. If the argument is a number, searches for characters that match the numeric ASCII value.
*/
Echo STRRCHR ($str, $s). "<br/>";
Echo MB_STRRCHR ($str, $s, ' utf-8 '). "<br/>";
Echo MB_STRRCHR ($str, $s, true, ' utf-8 '). "<br/>";
Echo MB_STRRCHR ($str, $s, false, ' utf-8 '). "
$str = "Hello world! Hello world! ";
$s = "world";
Echo STRRCHR ($str, $s). "<br/>";
Echo MB_STRRCHR ($str, $s, ' utf-8 '). "<br/>";
Echo MB_STRRCHR ($str, $s, true, ' utf-8 '). "<br/>";
Echo MB_STRRCHR ($str, $s, false, ' utf-8 '). "
/*
Definitions and usage
The STRTR () function converts a specific character in a string.
Grammar
STRTR (String,from,to)
Or
STRTR (String,array)
Parameter description
String1 required. Specify the string to convert.
From required (unless an array is used). Specify the characters to be changed.
To required (unless an array is used). Specify the character to change to.
Array is required (unless using from and to). An array in which the key is the original character and the value is the target character.
Description
If the length of from and to is different, it is formatted to the shortest length.
*/
Echo strtr ("Hilla Warld", "ia", "EO"). "<br/>";
$arr = Array ("Hello" => "Hi", "World" => "the Earth");
Echo strtr ("Hello World", $arr). "
Echo STRTR ("If omitted, use internal character encoding", "internal", "external"). "<br/>";
$arr = Array ("If", "=>", "=>");
Echo STRTR ("If omitted, use internal character encoding", $arr). "?>