Home > OS >  How to push data into array in php?
How to push data into array in php?

Time:07-13

I have two same variables

$newRow = $this->db->table(self::TABLE_NAME);
$rows = $this->db->table(self::TABLE_NAME);

with data from database

i want somehow push filtred data from variable $rows to variable $ newRow using this function but i dont know how to push it there

   $rows = $this->db->table(self::TABLE_NAME);
if ($showActiveOnly == 1) {
        $newRow = $rows->where(array('status' => 'dodano'));
    }
    $rows = $this->db->table(self::TABLE_NAME);
if($showNotAdded == 1){
        $newRow = $rows->where(array('status' => 'nedodano'));
    }

CodePudding user response:

You should understand what is the resultant output type of the data. If it is a Illuminate\Support\Collection then you can use $newRow->merge($rows);

If it is an array type then you can use $rows = array_merge($newRow, $rows);.

More information available below:

  •  Tags:  
  • php
  • Related