How does php process multiple values processed from the form at a time and use "|" as the separator between values?

Source: Internet
Author: User
How does php process multiple values processed from the form at a time and use "|" as the separator between values? For example, if you are interested in adding basketball or football, and so on, you can store them in the database as a field. | is used between football and basketball as the separator? How does php process multiple values processed from the form at a time and use "|" as the separator between values? For example, if you are interested in adding basketball or football, and so on, you can store them in the database as a field. | is used between football and basketball as the separator?

Reply content:

How does php process multiple values processed from the form at a time and use "|" as the separator between values? For example, if you are interested in adding basketball or football, and so on, you can store them in the database as a field. | is used between football and basketball as the separator?

If you wantHobbiesIf the field stores multiple data items, we recommend that youHobbiesStored as an array and used when stored in MySQLSerialize ()Serialization, used for readingUnserialize ()You can perform deserialization.

Serialization is a process of converting arrays or objects into strings so that they can be stored in the database.

// Example $ holobby = array ('basketball ', 'soccer', 'badminton ', 'computer'); echo serialize ($ Hober); // a: 4: {I: 0; s: 6: "basketball"; I: 1; s: 6: "football"; I: 2; s: 9: "badminton"; I: 3; s: 9: "computer ";}

How to UseSerialize ()For the series of functions, refer to the manual:

  • Serilize ()

  • Unserilize ()

I can probably understand what you mean. I thought the same way when I didn't understand the database at first. How to store multiple values in the same field, in fact, you only need to create a new data table, such as db_hoby, the field is "holobby user_id ".

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.