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:
- <Input name = "a []" value = "1"/>
- <Input name = "a []" value = "2"/>
- <Input name = "a []" value = "3"/>
- $ _ POST:
- Array
- (
- [A] => Array
- (
- [0] => 1
- [1] => 2
- [2] => 3
- )
- )
If the naming form is as follows:
- <Input name = "a [2]" value = "1"/>
- <Input name = "a [5]" value = "2"/>
- <Input name = "a [9]" value = "3"/>
- $ _ POST:
- Array
- (
- [A] => Array
- (
- [2] => 1
- [5] => 2
- [9] => 3
- )
- )
En, continue to test the PHP form array:
- <Input name = "a [aa]" value = "1"/>
- <Input name = "a [bb]" value = "2"/>
- <Input name = "a [cc]" value = "3"/>
-
- $ _ POST:
- Array
- (
- [A] => Array
- (
- [Aa] => 1
- [Bb] => 2
- [Cc] => 3
- )
- )
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...