简体   繁体   中英

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. 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函数,那么你的代码就会出错

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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