PHP String Handling functions

Source: Internet
Author: User

Tag:for   html    code    htm   re    ar   

One, the string output

1, Echo () Direct output 2, print () and echo as direct output, but there will be a return value 0 1

3, printf () formatted output    4, sprintf () returns the formatted string

strlen () computes the length of the string

Two, go to space and fill the string function

1, ltirm () Remove a space from the left or a defined character 2, RTrim () remove a space from the right or a defined character

3, trim () remove a space from both ends of a string or a defined character

4, Str_pad () fill the string

Three, case conversion

1, Strtoupper () all converted to uppercase 2, Strtolower () all to lowercase

3, Ucfirst () uppercase 4, ucwords () characters separated by spaces first uppercase

Four, and HTML related

1. NL2BR () Replace \ n with <br>

2, Htmlspecialchars () turns HTML tags into entities (entities are not parsed by the navigator)

3, htmlentities () Converts all non-ASC characters to the corresponding entity code

4, addslashed () adds the necessary backslash

5, Strip_tags () before the required character "\" to delete all or the specified HTML tags

V, String substitution and delimited connections

1, str_replace () Replace 2, explode () delimited 3, implode () connection

This will of course have a preg regular correlation function, followed by

VI, other

1, Strrev () Reverses the string

2, Number_format () formats the number as the standard currency format

3, MD5 () MD5 encryption

4, string comparison strcmp () case-sensitive comparisons and strcasecmp ( Ignore the case comparison of letters

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.