从foreach向url发送数据以传递codeigniter中的变量

sending data from foreach which is in the view 'header' in the url using json encode but the value is not passing to the variable and showing empty value in the controller 'user' here is the code

'header'(view)

<?php  foreach ($data as $key ):?>

    <?php echo anchor('user/dashboard/?data='.json_encode($key)  ,'Home'); ?><span class="sr-only">(current)</span></li>

now the controller 'user'

$data=json_decode($_GET['data']);
  print_r($data);
  $this->load->model('Pmodel'); 
 $email['data']=$this->Pmodel->select_model($data);

   $this->load->view('dashboard/dashboard',$email);

now when it goes to the controller it shows error

http://localhost/P_Display/user/dashboard/?data={

no value in the array

Look source document. Link is ok but is no good format html:

<a href="user/dashboard/?data="key3"">Home</a>

You must use urlencode:

foreach ($data as $key=>$value ) {
    echo anchor('user/dashboard/?data='.urlencode(json_encode($key)),'Home');
}

And

$data=json_decode(urldecode($_GET['data']));
print_r($data);
$this->load->model('Pmodel'); 
$email['data']=$this->Pmodel->select_model($data);

$this->load->view('dashboard/dashboard',$email);

Or you can use serialize (php).

:)