Array Value, solution

Source: Internet
Author: User
Array Value, solving PHPcode $ uc33; $ wcgetu_province (); foreach ($ wcas $ k & gt; $ v) {$ uv $ v [$ uc]; $ prolistjoin (0010. $ uc); foreach array value, solution
PHP code
        $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'];}               }      }



$ Wc Array ([0] => Array ([001011] => Beijing) [1] => Array ([001012] => Tianjin) [2] => Array ([001013] => Hebei )....)

How can I obtain the Chinese value of 001033? It seems that the above is not correct>?

------ Solution --------------------
0010 is fixed? Not understanding your code too much

PHP code
$ TestArray = array ('000000' => 'Beijing'), array ('000000' => 'Tianjin '), array ('20140901' => 'hebei '); // $ wc = getu_province (); $ uc = 12; $ find = '20160901 '. $ uc; foreach ($ testArray as $ value) {if (array_key_exists ($ find, $ value) {echo 'Region :'. $ value [$ find]; break ;}}
------ Solution --------------------
$ Uv = $ v ['$ UC'];
And
$ Uv = $ v ["$ uc"];
Is different.

------ Solution --------------------
$ Uc = 1,
"$ Uc" is "1 ",
'$ Uc' is the string "$ uc"
In double quotation marks, the variable name is replaced by the variable value before it is sent to the browser. this is not the case with single quotation marks.

------ Solution --------------------
Discussion

Test OK !!

By the way, $ v [$ uc] // $ v ['$ uc'] // $ v ["$ uc"]; the difference between them!

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.