Home > Blockchain >  Remove one index from the array in codeigniter controller
Remove one index from the array in codeigniter controller

Time:02-13

Array ( 
    [issuer_id] => in.gsvm 
    [org_id] => 00738648 
    [doc_type] => ABCDS 
    [RROLL] => 12589 
    [YEAR] => 2020 
)

I want to remove org_id from array and store that data in another variable

CodePudding user response:

Store the value in a variable:

$orgId = $array['org_id'];

and remove it from the array:

unset($array['org_id']);

It's just basic PHP, regardless of CodeIgniter.

CodePudding user response:

you can use php function unset() .

code :

$array = Array ( [issuer_id] => in.gsvm [org_id] => 00738648 [doc_type] => ABCDS [RROLL] => 12589 [YEAR] => 2020 );

unset($array['org_id']);

it removes index that you want to be removed from your array ; you can simply signed it to a variable before removing it .

code :

$array = Array ( [issuer_id] => in.gsvm [org_id] => 00738648 [doc_type] => ABCDS [RROLL] => 12589 [YEAR] => 2020 );

$ex_var = $array['org_id'] ; 
unset($array['org_id']);
  • Related