3v4l.org

run code in 300+ PHP versions simultaneously
<?php $db_rows = [ ['id' => 1, 'title' => 'test', 'number' => 2, 'desc' => 'test'], ['id' => 2, 'title' => 'test2', 'number' => 3, 'desc' => 'test2'], ['id' => 3, 'title' => 'test3', 'number' => 1, 'desc' => 'test3'], ]; $clone_db_rows = []; foreach( $db_rows as $key => $value ) { $clone_db_rows = array_merge( $clone_db_rows, // Merge the current array with... array_fill( // ...a newly created containing... 0, $value['number'], // ... X items equals to... $value // ... $value. ) ); } print_r($clone_db_rows);

preferences:
28.45 ms | 406 KiB | 5 Q