Usage of str_replace () character replacement function in php

Source: Internet
Author: User
Usage of str_replace () character replacement function in php
This article describes how to use str_replace () in php and related examples. For more information, see.

Define and use the str_replace function to replace other characters in a string with one character string. The str_replace (find, replace, string, count) parameter description is required. Specifies the value to be searched. Replace is required. Specifies the value to replace the value in find. String is required. Specifies the string to be searched. Count is optional. A variable that counts the number of replicas. Tip and comment: This function is case sensitive. Use str_ireplace () to perform a case-insensitive search. Note: This function is binary secure.

Let's take a look at several examples of str_replace () functions. only by looking at more examples and exercises can we improve the performance.

Example 1:

     

Output: Hello John!

Example 2:

     

Output: Array ([0] => blue [1] => pink [2] => green [3] => yellow) Replacements: 1

Example 3:

     

Output: Array ([0] => B [1] => [2] => !)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.