How to use PHP form arrays _ PHP Tutorial

Source: Internet
Author: User
Describes how to use PHP form arrays. Today we will introduce you to a problem about encoding. The Options form of the WP plug-in can define some form value variables. WP can help us to process, save, and repair them. what we will introduce today is related.Encoding. The Options form of the WP plug-in can define some form value variables. WP can help us directly process, save, and modify the content submitted by the form without any $ _ POST. But what if the content of the form I want to submit is a dynamically changing array? For example, a form is a dynamically generated inputbox list. how can I directly package the data into an array variable and pass it to WP without $ _ POST?

Suddenly thought of PHP form array:

 
 
  1. <Input name = "a []" value = "1"/>
  2. <Input name = "a []" value = "2"/>
  3. <Input name = "a []" value = "3"/>
  4. $ _ POST:
  5. Array
  6. (
  7. [A] => Array
  8. (
  9. [0] => 1
  10. [1] => 2
  11. [2] => 3
  12. )
  13. )

If the naming form is as follows:

 
 
  1. <Input name = "a [2]" value = "1"/>
  2. <Input name = "a [5]" value = "2"/>
  3. <Input name = "a [9]" value = "3"/>
  4. $ _ POST:
  5. Array
  6. (
  7. [A] => Array
  8. (
  9. [2] => 1
  10. [5] => 2
  11. [9] => 3
  12. )
  13. )


En, continue to test the PHP form array:

 
 
  1. <Input name = "a [aa]" value = "1"/>
  2. <Input name = "a [bb]" value = "2"/>
  3. <Input name = "a [cc]" value = "3"/>
  4. $ _ POST:
  5. Array
  6. (
  7. [A] => Array
  8. (
  9. [Aa] => 1
  10. [Bb] => 2
  11. [Cc] => 3
  12. )
  13. )

Then test the multi-dimensional array. Wow, that's cool!

A dynamically generated PHP form array can submit a lot of data only in the form of an array variable without relying on Javascript, solving the big trouble of developing this small WordPress plug-in.


Encoding encountered a problem. The Options form of the WP plug-in can define some form value variables. WP can help us process, save, and repair them directly...

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.