Home  >  Article  >  Backend Development  >  求高手 拯救小弟我PHP变量后面带[]是什么 意思

求高手 拯救小弟我PHP变量后面带[]是什么 意思

WBOY
WBOYOriginal
2016-06-13 12:36:35962browse

求高手 拯救我PHP变量后面带[]是什么 意思
我就贴上关键代码

<br />
foreach ($logData as $key => $data) {<br />
			$kItem[] = $key;//这里变量后面的[]是什么<br />
			$dItem[] = $data;<br />
			$cshu++;<br />
			if($cshu == 8) $dItem[] = "i";<br />
		}<br />
		$field = implode(',', $kItem);<br />
		$values = "'" . implode("','", $dItem) . "'";<br />
		$this->db->query("INSERT INTO " . DB_PREFIX . "blog ($field) VALUES ($values)");


循环读出数组 循环到第八个数据的时候 修改 $dItem[]的值为i 但是在写入数据的时候 这个I却是多出的
SQL语句执行错误:INSERT INTO emlog_blog (title,alias,content,excerpt,author,sortid,date,top,allow_remark,allow_tb,hide,password) VALUES ('dsa','','das','','39','-1','1380936471','n','i','y','y','n','') 
Column count doesn't match value count at row 1

报错的原因是因为多出了一个I值 我想把I前面的N替换掉的 但是不知道为什么他就是不能替换值

php
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