Home  >  Article  >  Backend Development  >  php post方式提交数组,该如何解决

php post方式提交数组,该如何解决

WBOY
WBOYOriginal
2016-06-13 12:15:411256browse

php post方式提交数组
想把array ( 1 => '1', 2 => '1', )提交到test数据库中table表的v2字段中,应该怎么写?
------解决思路----------------------
因為db字段里保存的是字符串,如果你傳數組進去,會強制轉為字符Array。數據就會丟失。
例如:
$arr = array(1,2,3,4);
echo $arr; // Array

所以先json_encode轉為字符串,讀取時再json_decode轉為數組。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn