数组取值,求解
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> $uc = 33; $wc = getu_province(); foreach ($wc as $k => $v) { $uv=$v['$uc']; $prolist = join('0010'.$uc); foreach ($uv as $s => $a) { if($a[0]=$prolist){ $ucc = $a['$prolist'];} } }
$testArray = array(array('001011' => '北京'), array('001012' => '天津'), array('001013' => '河北')); //$wc = getu_province(); $uc = 12; $find = '0010'.$uc; foreach ($testArray as $value) { if (array_key_exists($find,$value)){ echo '地区:' . $value[$find]; break; } } <br><font color="#e78608">------解决方案--------------------</font><br>$uv=$v['$uc'];<br>和<br>$uv=$v["$uc"];<br>是不一样的。<br> <br><font color="#e78608">------解决方案--------------------</font><br>$uc=1的话,<br>"$uc"就是"1",<br>'$uc'就是字符串"$uc"<br>因为双引号中,变量名称会被变量值所替代,然后才会发送给浏览器,而单引号就不会这样了。<br> <br><font color="#e78608">------解决方案--------------------</font><br>