Php5 and mysql5web development technical details-2 string operation_php tutorial

Source: Internet
Author: User
Php5 and mysql5web development technology-2 string operations. String learning is mainly to master built-in functions. There are too many functions, so far I have not remembered much. I will simply record the functions and then add them later. 1. Definition: single quotes and double quotes are used to learn built-in functions.

There are too many functions, so far I have not remembered much. I will simply record the functions and then add them later.

1. definition method: single quotation marks, double quotation marks, or {}

{} Easy to display index arrays, variable parsing with double quotation marks

2. manually convert string data

\ Symbol to implement

You can use the addslashes () and addcslashes () functions to customize the transfer.

3. serialize () and unserialize ()

4. string sorting

Trim (), ltrim (), rtrim ()

Remove spaces, line breaks (\ n, \ r), horizontal and vertical tabs (\ t, \ v), and string terminator (\ 0) from the string ).

5. format the string

Nl2br ()

Wordwrap ()

Strtolower ()

Strtoupper ()

Ucfirst ()

Ucwords ()

6. segmentation

Explode () and join () with the same name ()

Example: explode ("@", $ email );

7. string truncation

Substr ('Destination string', start point, end point)

8. strlen ()/mb_strlen ()

9. str_word_count ()

Use array_count_values () to calculate the number of times a word appears.

10. search for www.2cto.com

Strstr ($ string, "Keyword"), stristr (), strrch ()

Strpos ()

Str_repeat ()

Substr_count ()

11. handling

Str_replace ()

Substr_replace ()

Strrev ()

Htmlspecialchars () and htmlentitles () convert special characters such as <,>, &, and "to html entities

Strip_tags () clear html tag

Strncmp (), strcmp ()

Strok () parses strings

Strpbrk ()

Strspns (), strcspns ()

Str_replace ()

Bytes. There are too many functions, so far I have not remembered much. I will simply record the functions and then add them later. 1. Definition: single quotes, double quotes...

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.