foreach ($doorUserArray as $k =>$v) {
if (strpos($v, $need) !== false) {
echo "'$k' => '$v'<br />";
}
}
echo $v;//无效
想把$v的值拿出来 该怎么做
世界只因有你2017-06-26 10:51:18
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.
PHP中文网2017-06-26 10:51:18
Set a global variable and assign the value of $v to the global variable.
伊谢尔伦2017-06-26 10:51:18
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;