PHP Diary (a) string operation PHP Split string php string merge PHP string Exchange

Source: Internet
Author: User
Tags rtrim
First, the formatting of the string

1. Processing of strings: trim (), LTrim (), RTrim ()

$name =trim ($_post[' name "), $name =trim ($_post[' password ')), $name =trim ($_post[' email ');

The trim () function can strip the starting and ending spaces of a string and return the resulting string, by default the characters that are stripped are line feed and carriage return (\ n and \ r), Horizontal and Vertical tabs (\ T and x0b)

The LTrim () function removes spaces only from the beginning of the character (left)

The RTrim () function removes spaces only from the end of the function (right)

2. Format the string to display

① Using HTML formatting: n12br () function

Insert a newline character before a new line (\ n) in a string

 
   

Results
One line. Another line.

② formatting a string for print output

printf () structure

$s = "world");p rintf ("Hello%s", $s);

3. Change the case of letters in a string

Function Describe Using $subject =hello World return value
Strtoupper () Convert a string to uppercase Strtoupper ($subject) HELLO World
Strtolower () Convert a string to lowercase Strtolower ($subject) Hello World
Ucfirst () If the first character of a string is a character, capitalize it Ucfirst ($subject) Hello World
Ucwords () Capitalize the first letter of each word of a string Ucwords ($subject) Hello World


---------------------------------------------------------
Not finished

The above describes the PHP diary (a) string operations, including PHP, string aspects of the content, I hope to be interested in PHP tutorial friends helpful.

  • 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.