php 多维数组 arrayList array()

<pre name="code" class="php">$params=array(
		"tid"=>"3",
		"fid"=>"36",
		"uname"=>"tom",
		"title"=>"性感美女老师,高清图",
		"uid"=>"5",
		"times"=>"1412563750",
		"pid"=>"6",
		"first"=>"1",
		"content"=>"性感美女老师,高清图(3P)",
		"fjStatus"=>"2",
		"position"=>"1",
		"len"=>"52",
		"threadImgUrl"=>"201410/06/mccabcd1.jpg",
	    "attachments"=>[
						array(
								"aid"=>"6",
								"tableId"=>"1",
								"filename"=>"1.jpg",
								"size"=>"62910",
								"saveUrl"=>"201410/06/mccabcd1.jpg",
								"width"=>"500"
						),
						array(
								"aid"=>"7",
								"tableId"=>"1",
								"filename"=>"2.jpg",
								"size"=>"62910",
								"saveUrl"=>"201410/06/mccabcd2.jpg",
								"width"=>"500"
						),
						array(
								"aid"=>"8",
								"tableId"=>"1",
								"filename"=>"3.jpg",
								"size"=>"62910",
								"saveUrl"=>"201410/06/mccabcd3.jpg",
								"width"=>"500"
						),
						array(
								"aid"=>"9",
								"tableId"=>"1",
								"filename"=>"4.jpg",
								"size"=>"62910",
								"saveUrl"=>"201410/06/mccabcd4.jpg",
								"width"=>"500"
						)]);


 
 
循环调用:
<pre name="code" class="php">if(count($params["attachments"])>0)
  	{
  		foreach ($params["attachments"] as $fujian)
  		{
  			$aid=$fujian["aid"];
  			$tableId=$fujian["tableId"];
  			$filename=$fujian["filename"];
  			$size=$fujian["size"];
  			$saveUrl=$fujian["saveUrl"];
  			$width=$fujian["width"];
  			/*
		  	// // 附件表
		  	$query="";
		  	$query=sprintf("insert into pre_forum_attachment(aid,tid,pid,uid,tableid) VALUES('%s','%s','%s','%s',9)"
				  			,mysql_real_escape_string($aid)
				  			,mysql_real_escape_string($tid)
				  			,mysql_real_escape_string($pid)
				  			,mysql_real_escape_string($uid));
		  	mysql_query($query) or die(mysql_error());
		  	
		
		  	// // 附件表2
		  	$query="";
		  	$query=sprintf("insert into pre_forum_attachment_1(aid,tid,pid,uid,dateline,filename,filesize,attachment,isimage,width)"
						  ."VALUES('%s','%s','%s','%s','%s','%s','%s','%s',1,'%s')"
				  			,mysql_real_escape_string($aid)
				  			,mysql_real_escape_string($tid)
				  			,mysql_real_escape_string($pid)
				  			,mysql_real_escape_string($uid)
				  			,mysql_real_escape_string($times)
				  			,mysql_real_escape_string($filename)
				  			,mysql_real_escape_string($size)
				  			,mysql_real_escape_string($saveUrl)
				  			,mysql_real_escape_string($width));
		  	mysql_query($query) or die(mysql_error());
		  	
  		}
  	} 


 

转载于:https://www.cnblogs.com/raphael5200/p/5114847.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值