- BASICS
- Quotes
- Constants
- Control Structures
- Reference
- Number Systems
- VARIABLES
- Definition
- Variable Variable
- Exists
- Type Casting
- OPERATORS
- Aritmetic
- Bitwise
- String
- Comparison
- Logical
- FUNCTION
- Definition
- Anonymous
- Reference
- Variable Arguments
- ARRAY
- Basics
- Operations
- Create
- Search
- Modify
- Sort
- Storage
- STRING
- String Basics
- String Compare
- String Search
-
String Replace
- String Format
- String Regexp
- String Parse
- Formating
- Json
- STREAMS
- File Open
- Read File
- Read Csv
- File Contents
- Context
- Ob_start
- OOP
- Object Instantiation
- Class Constructor
- Interfaces, Abstract
- Resource Visibility
- Class Constants
- Namespaces
- HTTP
- Headers
- File Uploads
- Cookies
- Sessions
Replace
Replaces all occurrences of the search string with the replacement string.
echo str_replace("EN ", "RO ",
"EN dictionary for En class");
// RO dictionary for En class
echo str_ireplace("EN ", "RO ",
"EN dictionary for En class", $count);
// $count = 2
Translate
Translates characters or replace substrings.
echo strtr("baab", "ab", "01"); // 1001
echo strtr("This is America", array('This'=>'Acesta', 'is'=>'e'));
// Acesta e America
Substring
Returns: string OR array
echo substr_replace("123456", "a", 0); // a
echo substr_replace("123456", "a", 2); // 12a
echo substr_replace("123456", "a", -1); // 12345a
echo substr_replace("123456", "a", -2); // 1234a
echo substr_replace("123456", "a", 0, 2); // a3456
echo substr_replace("123456", "a", 0, -2); // a56
echo substr_replace("123456", "a", 0, 0); // a23456
Last update: 531 days ago