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;