I have problem in deleting an element of array. Look:
<?php
session_start();
$i = 0;
$expected = $_GET['name'];
foreach($_SESSION['chart'] as $name)
{
if($name==$expected)
{
break;
}
$i++;
}
unset($_SESSION['chart'][$i]);
echo count($_SESSION['chart'])." ".$expected." ".$i;
//echo "<script>history.go(-1);</script>";
?>
I’m getting this output: 3 name 2.
I know that element in array exists with name ‘name’, but I can’t unset it. Please help me.
Why not let PHP do the search?