关于数组取值的问题!
//已知数组$info=array();//输出print_r($info);//结果Array( [0] => Array ( [name] => 8.gif [md5] => b68d88dbdfc9d0af2e0bbd85a4ccd28f [saveName] => 20120602080557_452.gif [size] => 1 [type] => image/gif [originalHeight] => 39 [originalWidth] => 31 ) [1] => Array ( [name] => 9.gif [md5] => 4988f85ebebf82f56d70eeaf39a67016 [saveName] => 20120602080557_776.gif [size] => 2 [type] => image/gif [originalHeight] => 39 [originalWidth] => 31 ))
foreach($info as $value){foreach($value as $getValue){echo $getValue['saveName'];}}
[解决办法]
foreach($info as $v) $temp[]=$v['saveName'];
print_r($temp);
[解决办法]
看来name是类似于唯一字段了,想取出来和name对应的savename字段。如果这样的话,需要接收你给的name字段值,当你用post表单提交的吧。
二维数组。一个foreach判断就够了
$a=Array( Array ( 'name' => '8.gif', 'md5' => 'b68d88dbdfc9d0af2e0bbd85a4ccd28f' , 'saveName' => '20120602080557_452.gif', 'size' => 1 , 'type' => 'image/gif' , 'originalHeight' => 39 , 'originalWidth' => 31 ),Array( 'name' => '9.gif' , 'md5' => '4988f85ebebf82f56d70eeaf39a67016', 'saveName' => '20120602080557_776.gif' , 'size' => 2 , 'type' => 'image/gif' , 'originalHeight' => 39 , 'originalWidth' => 31 , )) ;foreach ($a as $k=>$v) {if ($v['name']===$_POST['yourname']){//令$_POST['yourname']=‘8.gif’,将输出$v ['saveName']=20120602080557_452.gifecho '$v ['.'savename'.']='.$v ['saveName'] .'<br>' ; } } ?>