How PHP handles multiple values processed from a form at once, with a "| |" Do the separators?

Source: Internet
Author: User
How PHP handles multiple values processed from a form at once, with a "| |" Do the separators? For example, hobbies add basketball, soccer, and so on as a field stored in the database, between football and basketball with | | As a delimiter?

Reply content:

How PHP handles multiple values processed from a form at once, with a "| |" Do the separators? For example, hobbies add basketball, soccer, and so on as a field stored in the database, between football and basketball with | | As a delimiter?

Not quite understand your problem, if you want to store multiple data in the field, it is 爱好 recommended that all the 爱好 storage array form, in MySQL when the use of serialize() serialization, read the use of deserialization unserialize() on it.

Serialization is the process of converting an array or an object into a string so that it can be stored in a database.

//Example$hobby = array('篮球', '足球', '羽毛球', '计算机');echo serialize($hobby);//a:4:{i:0;s:6:"篮球";i:1;s:6:"足球";i:2;s:9:"羽毛球";i:3;s:9:"计算机";}

For information on how to use the serialize() series functions, refer to the manual:

  • Serilize ()

  • Unserilize ()

I can probably understand what you mean, I did not understand the database at first I think so, how to store multiple values in the same field, you just need to create a new data table, such as Db_hobby, the field is "hobby user_id" can

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