How to unset specific data array in codeigniter

Its been two days I'm working with these guys. Need help here.

here is my view

$username = json_decode($this->session->userdata('users'), TRUE);

    foreach ($username AS $key => $value) {

    <?php echo $value['username']; ?>
    <?php echo $value['firstname']; ?>
    <?php echo $value['lastname']; ?>
    <?php $u = $value['username']; ?>
    <?php echo "<a href=".base_url()."index.php/bets/un_sess/$u /> X </a> " ?>

    <?php } ?>

here is my controller

$user1 = json_decode($this->session->userdata('users'), TRUE);
 foreach ($user AS $key => $value) {
       $index = array_search($username, $user);
      $this->session->set_userdata('users', $user);

array from user_data


the output of this is when the first time i click the username its working but when i click another username it gives error like this

A PHP Error was encountered

Severity: Warning

Message: Illegal offset type in isset or empty

Filename: libraries/Session.php

Line Number: 433 A PHP Error was encountered

Severity: Warning

Message: Invalid argument supplied for foreach()

Filename: controllers/bets.php

Line Number: 290


ok since there is no answering in my questions. Here is my solutions

 $user = json_decode($this->session->userdata('users'), TRUE);
        foreach ($user AS $key => $value) {
          if ($username == $value['username']){


       $this->session->set_userdata('users', json_encode($user));

Need Your Help

Add ETag using IHttpModule httpmodule etag

I have wrote a simple IHttpModule

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.