<?php $n = 3;$m = 2; $array = [1, 2, 3, 4, 5, 6, 7]; $i = array_search($n, $array);$result = array_merge(array_slice($array, $i), array_slice($array, 0, $i)); var_dump($result);
Standard input is empty
array(7) { [0]=> int(3) [1]=> int(4) [2]=> int(5) [3]=> int(6) [4]=> int(7) [5]=> int(1) [6]=> int(2) }
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!