php uses session two dimensional array instances

  • 2021-07-24 10:35:15
  • OfStack

This article illustrates how php uses session 2-dimensional arrays. Share it for your reference. The details are as follows:

Most common usage: 1 variable name

$_SESSION['user'] = 0;
echo $_SESSION['user'];

Using arrays:
$_SESSION['user']['a'] = 1;
$_SESSION['user']['b'] = 2;
echo $_SESSION['user']['a'];
echo $_SESSION['user']['b'];

The advantage of this is that it can be grouped.

If you can use:
$_SESSION['admin']['a'] = 11;
$_SESSION['admin']['b'] = 22;

I hope this article is helpful to everyone's PHP programming.


Related articles: