• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to get ids from session in codeIgniter

#1
Star 
I want to know is there any way to get all qids without using foreach loop.


PHP Code:
$data=array( 
             
'position' =>$row->pos,
 
            'qid' =>$row->id
        
);
                    
$items=$this->session->userdata('mcqs');                  

$items
[]=$data;

$mcqs=$this->session->set_userdata('mcqs'$items); 

PHP Code:
Array
(
 
  [0] => Array
 
      (
 
          [position] => 5
           
[qid] => 3
       
)
 
  [1] => Array
 
      (
 
          [position] => 6
           
[qid] => 4
       
)

 
  [2] => Array
 
      (
 
          [position] => 2
           
[qid] => 5
       
)

 
  [3] => Array
 
      (
 
          [position] => 4
           
[qid] => 1
       
)



 please help  me .
Reply

#2
PHP Code:
$qids array_column($array,'qid'); 
For more information:
http://php.net/manual/en/function.array-column.php
Reply

#3
@Wouter60

It is exactly what i am looking for.

Thanks
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.