时间:2021-07-01 10:21:17 帮助过:14人阅读
$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; } }
------解决方案--------------------
$uv=$v['$uc'];
和
$uv=$v["$uc"];
是不一样的。
------解决方案--------------------
$uc=1的话,
"$uc"就是"1",
'$uc'就是字符串"$uc"
因为双引号中,变量名称会被变量值所替代,然后才会发送给浏览器,而单引号就不会这样了。
------解决方案--------------------