从特定字符串开始计算活动和打印活动会话[关闭]

Hi is there a way to count active and print active session starting with a specific string?

For example, I want to count session that has a name starting with "question"

Assuming that we are using the $_SESSION array and the names are done similar to:

$_SESSION["question1"] = "foo";
$_SESSION["question2"] = "bar";
...

Loop through the array and check if "question" is inside each string by using strstr():

foreach ($_SESSION as $key => $value) 
    if(strstr($key, "question"))
        print $value;