In phppost mode, if you want to submit an array (1 => '1', 2 => '1',) to the v2 field of the table in the test Database, how should we write it?
Reply to discussion (solution)
First? And then json_encode in?
$ Arr = array (1 => '1', 2 => '1 ');
$ V2 = json_encode ($ arr );
$ SQL = "insert into table (v2) values ('". $ v2 ."')";
First? And then json_encode in?
$ Arr = array (1 => '1', 2 => '1 ');
$ V2 = json_encode ($ arr );
$ SQL = "insert into table (v2) values ('". $ v2 ."')";
Sorry, I may not be very clear about it,
For example:
1. php
$ V2 = $ _ POST ['V2'];
Print_r ($ v2); you can get Array ([0] => 1 [1] => 2). when submitting data to the database, only Array is available, I want to submit the entire Array ([0] => 1 [1] => 2) to the field.
First? And then json_encode in?
$ Arr = array (1 => '1', 2 => '1 ');
$ V2 = json_encode ($ arr );
$ SQL = "insert into table (v2) values ('". $ v2 ."')";
As mentioned above, I will reference $ v2 = json_encode ($ _ POST ['V2']) and add $ v2 to the database.
Json_encode: decode it when it is obtained ..
Why store data such as 'array ([0] => 1 [1] => 2) 'in the field.
First? And then json_encode in?
$ Arr = array (1 => '1', 2 => '1 ');
$ V2 = json_encode ($ arr );
$ SQL = "insert into table (v2) values ('". $ v2 ."')";
As mentioned above, I will reference $ v2 = json_encode ($ _ POST ['V2']) and add $ v2 to the database.
$ V2 = json_encode ($ _ POST ['V2']); submit it to the database to get ["1", "2"]. I want to submit it to get Array (1 => 1 ,) this way
Json_encode: decode it when it is obtained ..
Why store data such as 'array ([0] => 1 [1] => 2) 'in the field.
The reading format of a cms is like this.
Json_encode: decode it when it is obtained ..
Why store data such as 'array ([0] => 1 [1] => 2) 'in the field.
The reading format of a cms is like this.
Just convert it into an array when reading it.
Json_encode: decode it when it is obtained ..
Why store data such as 'array ([0] => 1 [1] => 2) 'in the field.
The reading format of a cms is like this.
Just convert it into an array when reading it.
Little Cainiao is studying hard. I don't know much about it in many places !! Ask for advice ..
Because? The db field stores a string. if you are ???? Go ,?? ?? Character Array .?? ?? Loss.
For example:
$ Arr = array (1, 2, 4 );
Echo $ arr; // Array
So json_encode first ?? String ,? ? Then json_decode ????.
Because? The db field stores a string. if you are ???? Go ,?? ?? Character Array .?? ?? Loss.
For example:
$ Arr = array (1, 2, 4 );
Echo $ arr; // Array
So json_encode first ?? String ,? ? Then json_decode ????.
Thank you, moderator.