Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to push data into array in php?

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

   $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'));
    }

>Solution :

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:

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading