[英]Php post json data
I have a simple form with 2 fields and I want to read the data from it and use it with $_POST
. 我有一个包含2个字段的简单表单,我想从中读取数据并与
$_POST
一起使用。
This is the output when I debug the $_POST
function: 这是我调试
$_POST
函数时的输出:
file_put_contents( 'debug' . time() . '.log', var_export( $_POST, true));
OUTPUT: 输出:
array (
'form' =>
array (
'id' => '36e3113',
'name' => 'New Form',
),
'fields' =>
array (
0 =>
array (
'id' => '0',
'type' => 'text',
'title' => 'Your name',
'value' => 'John',
'raw_value' => 'John',
'required' => '1',
),
1 =>
array (
'id' => '1',
'type' => 'tel',
'title' => 'Phone number',
'value' => '12345',
'raw_value' => '12345',
'required' => '1',
),
),
)
I want to use $POST
to only assign values of Your name
to $name
and Phone number
to $number
variable. 我想使用
$POST
仅将Your name
值分配给$name
,将Phone number
分配给$number
变量。
You can get it like. 你可以得到像。
$name = $_POST['fields'][0]['value'];
$number = $_POST['fields'][1]['value'];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.