foreach ($doorUserArray as $k =>$v) {
if (strpos($v, $need) !== false) { echo "'$k' => '$v'<br />"; } } echo $v;//无效 想把$v的值拿出来 该怎么做
According to the principle of program execution from top to bottom, declare a variable before foreach, and then assign the value directly inside the foreach loop. If you have any questions, you can reply at any time.
Set a global variable and assign the value of $v to the global variable.
Scope issue, before looping, set a variable externally, or extract it and make it a function and return the result
function xyz(){ ... return $v; } var toEcho = xyz(); echo toEcho;
According to the principle of program execution from top to bottom, declare a variable before foreach, and then assign the value directly inside the foreach loop. If you have any questions, you can reply at any time.
Set a global variable and assign the value of $v to the global variable.
Scope issue, before looping, set a variable externally, or extract it and make it a function and return the result