Home > Backend Development > PHP Tutorial > 数组取值,求解解决方案

数组取值,求解解决方案

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 13:38:51
Original
936 people have browsed it

数组取值,求解

PHP code
<!--

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'];}
               }
      }
Copy after login



$wc 类似于这样的东西Array ( [0] => Array ( [001011] => 北京 ) [1] => Array ( [001012] => 天津 ) [2] => Array ( [001013] => 河北 )....)

需要取001033的中文值,,,,怎么取? 好像上面写的不太对么>?

------解决方案--------------------
0010是固定的?没太看懂你的代码

PHP code

$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>
Copy after login
探讨

test OK !!

顺便求问$v[$uc] // $v['$uc'] // $v["$uc"];三者的差别!
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
How to create an array within an array?
From 1970-01-01 08:00:00
0
0
0
php array
From 1970-01-01 08:00:00
0
0
0
Array to array
From 1970-01-01 08:00:00
0
0
0
php array rotation
From 1970-01-01 08:00:00
0
0
0
array
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template