Replace
$MyString = str_replace('ReplaceThis', 'WithThis', $MyString);
$domain = str_replace('www.', '', $domain); //Remove leading www. from $domain
Case insensitive
str_ireplace() is a case-insensitive version of str_replace()
$MyString= str_ireplace("one", "1", $MyString); //Replace "OnE" with "1"
Replace whitespace
Replace single and multiple occurrences of white space with a comma
$MyString= preg_replace('/\s+/', ',', $MyString); //Replace single and multiple occurrence of white space with a comma
Pad string to fixed length
$MyString = "Apple"
$RequiredLength = 26;
$PadWithString = "*~*"
$MyString = str_pad($MyString, $RequiredLength, $PadWithString, STR_PAD_BOTH);
//Will give: "*~**~**~**Apple*~**~**~**~"
$MyString = str_pad($MyString, $RequiredLength, $PadWithString, STR_PAD_RIGHT);
//Will give: "Apple*~**~**~**~**~**~**~*"
$MyString = str_pad($MyString, $RequiredLength, " ", STR_PAD_RIGHT);
//Will give: "Apple "
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.