删除并更新数组[关闭]

i have this code

$_SESSION['id'][] = $link;

this is work true and result like this

Array ( [id] => Array ( [0] => 4 [1] => 3 [2] => 2 [3] => 1 [4] => 4 [5] => 4 [6] => 1 [7] => 1 [8] => 1 [9] => 1 [10] => 1 [11] => 1 [12] => 1 ) ) 

i want show every index single out of array

foreach($_SESSION as $key=>$value){
    echo $key;
    echo $value;
    echo $_SESSION[$key][$value];
    echo '<br />';
}

how to can?

this is result of foreach

id Notice: Array to string conversion in ajax\ajax.php on line 18
Array Warning: Illegal offset type in ajax\ajax.php on line 19

line 18 and 19

echo $value;
echo $_SESSION[$key][$value];

just loop through the $_SESSION['id'] array not the $_SESSION array

foreach($_SESSION[id] as $value){
    echo $value;
    echo '<br />';
}

Is it?

foreach($_SESSION['id'] as $key=>$value){
    echo $key;
    echo $value;
    echo "$key:$value";
    echo '<br />';
}

I think you are looping in the wrong array level as you need to get id

Simply change to

foreach($_SESSION['id'] as $key=>$value){
    echo "$key=>$val" . "<br>";
}

$_SESSION['id'] is an array. But If you want to iterate on all the contents from $_SESSION than I think this should help!

foreach($_SESSION as $key => $value)
{
    if(is_array($value))
    {
        foreach($value as $k => $v)
        {
           echo $key."[".$k."] = ".$v ;
        }
    }else{
        echo $key." = ".$value;
    }

}