!--? Php$array = Array (0 =--> array (' 1a ' + = ', ' 3a ' = =) ', ' 6a ' = = Array (' 6a1 ' = ' = ', ' 6a2 ' = = ', ' 6a3 ' = = Array (' 6a31 ' = ', ' 6a33 ' = ' = ', ' 6a34 ' = ' 1 ', '), '), 1 = = Array (' 3b ' = = ') ', ' 4b ' = = Array (' 4b1 ' = ' = ', ' 4b2 ' = ', '), ' 6b ' = = ', ') '; function Search_val ($key, $arr) {$v = '; foreach ($arr as $ks = + $vs) {if ($ks! = $key && Is_array ($vs)) {Search_val ($key, $vs); }else if ($ks! = $key && is_string ($vs)) {continue; }else if ($ks = = $key) {$v = $vs; Break }} return $v; Var_dump ($v); exit; Here is the value for 1//echo $v; The test can be directly output} $va = Search_val (' 6a34 ', $array); Var_dump ($VA); $va is always empty
The meaning of this method is to give $key the label out val the corresponding value, I at the end of the method return $v , and then I return assign the result to a value $va , this value is always empty, but I was the method at the end of the printing $v is a value, why this? Is it a variable scope problem or is my code written in a non-canonical cause? Solving