简体   繁体   English

inarray函数不适用于设置为array的会话变量

[英]inarray function won't work with session variable that is set to array

Everytime the script that contains the inarray function executes, the element disappears and the ones that comes after it. 每次包含inarray函数的脚本执行时,元素都会消失,而后面的元素会消失。 I believe it means that it's not working. 我相信这意味着它不起作用。 I set the session variable to an array just like setting a regular variable to an array. 我将会话变量设置为数组,就像将常规变量设置为数组一样。

$items = array("A", "B", "C");
$_SESSION["item"] = $items;

if(inarray("A", $_SESSION["item"])) { echo "An item!"; }

This doesn't work. 这不起作用。 I can't get the echo to work. 我无法让回声发挥作用。 On top of that, the elements that comes after it disappears indicating that it doesn't work? 最重要的是,它之后的元素消失,表明它不起作用?

如果你的意思是标准的in_array函数,那么你的代码就会出错

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM