2
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

0

3 Answers 3

2

You can use unset().

php > $array = Array (0 => 123, 1 => 456);
php > unset($array[0]);
php > print_r($array);
Array
(
    [1] => 456
)

It destroys the variable, which in this case is the array item matching the index that you want to delete.

You assign the value to a new variable before removing it.

php > $array = Array (0 => 123, 1 => 456);
php > $v = $array[0];
php > unset($array[0]);
php > print_r($array);
Array
(
    [1] => 456
)
php > echo $v;
123

Sign up to request clarification or add additional context in comments.

Comments

1

Store the value in a variable:

$orgId = $array['org_id'];

and remove it from the array:

unset($array['org_id']);

This is just ordinary PHP which works the same in CodeIgniter.

Comments

0

You can use unset(array) method of PHP programming language to remove an item. for example

$dataArray = ['key1'=>'data1','key2'=>'data2'];

unset($dataArray['key1']);

Then pass the array to insert function.

$this->db->insert('table_name',$dataArray);

You can find details example on this link: https://www.techiedelight.com/remove-elements-array-php/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.