String replacement, segmentation, and connection

Source: Internet
Author: User

String replacement 1. execute a regular expression to search for and replace mixed preg_replace (mixed $ pattern, mixed $ replacement, mixed $ subject [, int $ limit =-1 [, int & $ count]) search for the part in the subject that matches pattern and replace it with replacement. 2. replace the child string with mixed str_replace (mixed $ search, mixed $ replace, mixed $ subject [, int & $ count]). This function returns a string or array. This string or array is the result after all the searches in the subject are replaced by replace. String separation and connection use a regular expression to separate string description 1. array preg_split (string $ pattern, string $ subject [, int $ limit =-1 [, int $ flags = 0]) separates a given string using a regular expression. 2. explode-when one string is used to separate another string, it indicates array explode (string $ separator, string $ string [, int $ limit]) $ str = 'one | two | three | four '; // positive limitprint_r (explode ('|', $ str, 2); // negative limit (from PHP 5.1) print_r (explode ('| ', $ str,-1); the preceding routine will output: Array ([0] => one [1] => two | three | four) array ([0] => one [1] => two [2] => three) 3. string implode (string glue, array pieces) // The connected array is called the string $ lan = array ("a", "B", "c"); implode ("+ ", $ lan); // a + B + c

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.