Array values, solving solutions

Source: Internet
Author: User
Array values, solving
PHP Code
  
         $uc =;      $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 '];               }      }



$WC something like this array ([0] = = Array ([001011] [+] = Beijing) [1] = = Array ([001012] = Tianjin) [2] = = Array ([001013] (Hebei) ...)

Need to take 001033 of the Chinese value,,,, how to take? It seems that the above is not very right to say;

------Solution--------------------
Is the 0010 fixed? I don't really understand your code.

PHP code
 $testArray = Array (' 001011 ' = ' = ' Beijing '), Array (' 001012 ' = ' Tianjin '), Array (' 001013 ' = ' Hebei ');//$WC = Getu_province (); $uc = n; $find = ' 0010 '. $uc; foreach ($testArray A        S $value) {if (Array_key_exists ($find, $value)) {echo ' region: '. $value [$find];    Break }} 
------solution--------------------
$uv = $v [' $uc '];
and
$uv = $v ["$uc"];
is not the same.

------Solution--------------------
$uc = 1,
"$uc" is "1", and
' $uc ' is the string "$uc"
because in double quotes, the variable name is replaced by the value of the variable. Then it will be sent to the browser, and the single quotes will not.

------Solution--------------------
Explore

Test OK!!

by the way $v[$uc]//$v [' $UC ']//$v ["$uc"]; three differences!
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.