Jump to content

remove empty element of session array


robert_gsfame

Recommended Posts

<?php

$id=urldecode(base64_decode($_GET['product_id']));

$explode=explode(";",$id);

$count=count($explode);

for($i=0;$i<$count;$i++)

{

  if(in_array(base64_encode($explode[$i]),$_SESSION['basket']))

    {

      $x="";

      $x=array_search(base64_encode($explode[$i]),$_SESSION['basket']);

      unset($_SESSION['basket'][$x]);

    }

}

 

?>

 

The problem is let say i have 3 records and unset() 2 of them, i will still have 1 record but i dont know which part is wrong, i got it not as a first index of an array which is $_SESSION['basket'][0] but $_SESSION['basket'][1]

 

i found $_SESSION['basket'][0] empty

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/208631-remove-empty-element-of-session-array/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.