$str="bar";
$str[1] = 'A';
echo $str; // prints bAr
or you could use the library function substr_replace
as:
$str = substr_replace($str,$char,$pos,1);
More Related Contents:
- How do I replace certain parts of my string?
- PHP string replace match whole word
- how to replace special characters with the ones they’re based on in PHP?
- Replace last occurrence of a string in a string
- Search and replace multiple values with multiple/different values in PHP5?
- PHP remove commas from numeric strings
- Search and replace multiple values with multiple/different values in PHP?
- How can I get a hex dump of a string in PHP?
- Remove new lines from string and replace with one empty space
- URL Friendly Username in PHP?
- PHP: Split string [duplicate]
- Mixing a PHP variable with a string literal
- PHP equivalent of .NET/Java’s toString()
- How to mimic Stack Overflow Auto-Link Behavior
- Remove control characters from PHP string
- Convert flat array to a delimited string to be saved in the database
- Split string by new line characters
- string sanitizer for filename
- PHP function to delete all between certain character(s) in string
- How do you pull first 100 characters of a string in PHP
- How to convert a string to JSON object in PHP
- Get the first letter of each word in a string
- Close open HTML tags in a string
- Return the portion of a string before the first occurrence of a character in PHP [duplicate]
- How to check if letter is upper or lower in PHP?
- Why a function checking if a string is empty always returns true? [closed]
- How to get the first word of a sentence in PHP?
- How to convert array values to lowercase in PHP?
- Format 32-character string with hyphens to become UUID
- finding common prefix of array of strings