About PHP Array to string details _php tutorial

Source: Internet
Author: User
Tags array to string
With the development of the Times, our development technology also with the update, for PHP or more commonly used, so I studied the PHP array to the string, here to take out and share with you, hope to be useful to everyone.

It is often necessary to use PHP to handle characters string,php built-in character functions that provide a very powerful function that basically completes most character processing operations. If you use the Str_split function to convert a character to an array, the IMPLODE function converts the PHP array to a string, the Strpos function looks for another character in one character, the substr function gets a few characters in the character, the strlen function gets the character length, and so on. These are the most basic knowledge of PHP, convenient for daily use, I will do some summary of this function, for reference only.

1, how to convert a character to an array
Workaround: Str_split () function
Examples are as follows:

 
  
  
  1. $ biuuu ' www.biuuu.com ';
  2. Print_r (Str_split ($BIUUU))

Output Result:

 
  
  
  1. Array
  2. (
  3. [0] => b
  4. [1] => i
  5. [2] => u
  6. [3] => u
  7. [4] => u

2, how to convert a PHP array to a string
Workaround: Implode () function
Examples are as follows:

 
  
  
  1. $ biuuu Array(' B ', ' I ', ' u ', ' u ', ' U ');

Output result Biiuu

3, how to find another character in one character
Workaround: Strpos or Strstr
Examples are as follows:

 
  
  
  1. $ biuuu ' This is my website biuuu.com ';
  2. $ Search ' biuuu ';

Output results: 19

4, how to get a few characters in a character
Workaround: substr () function
Examples are as follows:

 
  
  
  1. $ biuuu ' This is my website biuuu.com ';

Output Result: biuuu.com

5, how to get the character length
Workaround: strlen () function
Examples are as follows:

 
  
  
  1. $ biuuu ' This is my website biuuu.com ';

Output Results 28

The above several PHP character processing functions str_split, implode, Strpos, substr and strlen in the actual development because often need to use, hope to be helpful to everybody.


http://www.bkjia.com/PHPjc/446527.html www.bkjia.com true http://www.bkjia.com/PHPjc/446527.html techarticle with the development of the Times, our development technology also with the update, for PHP or more commonly used, so I studied the PHP array to string, here to take out and share with you ...

  • Related Article

    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.