- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
strtr() function in PHP
The strstr() is used to translate a character or replace substring.
Syntax
strstr(str, from, to) or strstr(str, arr)
Parameters
str − The string to translate
from − The characters to change. A required parameter if array is not used.
to − The characters to change into. A required parameter if array is not used.
arr − Array containing what to change from as key, and what to change to as value
Return
The strstr() function returns the translated string.
Example
The following is an example −
<?php $mystr = "kom lan" ; $str1 = "koml"; $str2 = "tomh"; echo strtr($mystr, $str1, $str2); ?>
Output
tom han
Advertisements