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!