I'm trying to unset a certain value in a session array in php. I would like to ask if there's a better way in doing this:
<?php
session_start();
if(isset($_GET['Uname'])){
echo "Uname is set!";
$uname=$_GET['Uname'];
echo count($_SESSION['user']);
for($x=0; $x < count($_SESSION['user']); $x++ ){
if($_SESSION['user'][$x]['Uname']==$uname){
unset($_SESSION['user'][$x]['Uname']);
}
}
}else{
}
?>
Is it possible to accomplish the same thing using a foreach loop?Or another method