关于数组取值的问题!
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> //已知数组 $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']; } } <br><font color="#e78608">------解决方案--------------------</font><br>foreach($info as $v) $temp[]=$v['saveName'];<br>print_r($temp); <br><font color="#e78608">------解决方案--------------------</font><br>看来name是类似于唯一字段了,想取出来和name对应的savename字段。如果这样的话,需要接收你给的name字段值,当你用post表单提交的吧。<br><br>二维数组。一个foreach判断就够了<br><br>
$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.gif echo '$v ['.'savename'.']='.$v ['saveName'] .'<br>' ; } } ?> <div class="clear"> </div>