PHP Arrays converted to strings

Source: Internet
Author: User

1. function explode (); This is the string conversion to an array, implode (); This is the conversion of arrays to strings.

$array =explode (separator, $string);
$string =implode (glue, $array);

The key to using and understanding these two functions is the delimiter (separator) and the glue (glue) relationship. When you convert an array to a string, you will set the glue--the character or code that will be inserted between the array values in the generated string.

1. When I am working on a project, I always run into a SQL statement to determine if this value is not in between.

SELECT* from ' shipping_types ' where  ' id '   IN 1< Span class= "syntax_punct syntax_punct_listsep" >, 2 < Span class= "syntax_punct syntax_punct_bracket_close_round")   limit 0 , 30

When we use in, the value inside is an array from the database, we are going to convert, we are going to convert the array to a string.

PHP gives us a function:

$arr: Array.

$string = Implode (', ', $arr);

PHP Arrays converted to strings

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.