str_replace() Hàm thay thế chuỗi

  • Thread starter Thread starter root
  • Ngày gửi Ngày gửi

root

Specialist
1. cú pháp:
PHP:
str_replace(find,replace,string,count)

  • find: sẽ tìm chuỗi trong string
  • replace: Nếu tìm thấy chuỗi cần tìm trong string thì thực hiện thay thế chuỗi tìm được bằng chuỗi mới replace
  • String: chuỗi ban đầu
2. Ví dụ:
- Code:
PHP:
<?php
echo str_replace("world","Peter","Hello world!");
?>
- Kết quả:
HTML:
Hello Peter!
 
Back
Top