3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = array ( 'rows' => array ( 0 => array ( 'position' => 1, 'image_id' => 2809, 'basename' => 'rj5ed2c90f609423.26673093.jpg' ), 1 => array ( 'position' => 1, 'image_id' => 2808, 'basename' => 'rj5ed2c8eccc9c06.91700011.jpg' ), 2 => array ( 'position' => 2, 'image_id' => 2807, 'basename' => 'rj5ed2c77ef32b76.96579137.jpg' ) ) ); $data['rows'] = array_reduce($data['rows'], function ($c, $a) { $c[$a['position']][] = $a; return $c; }, array()); print_r($data);

preferences:
117.06 ms | 405 KiB | 5 Q