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);
unset($user[$index]);
$this->session->set_userdata('users', $user);
array from user_data
{"username":"user1","firstname":"name1","lastname":"name2"},
{"username":"user2","firstname":"test","lastname":"test"}
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
$user1and then using$userin foreach - Uttara