php - How to pair items in array -
how pair items in array
$array= array(1,2,3,4,5,6,7,8,9);
i display array as
12
23
34
45
56
67
78
89
how can achieve this?
this code looking for:
$array= array(1,2,3,4,5,6,7,8,9); for($i=0;$i<count($array);$i++){ if (isset($array[$i+1])) // mentioned in comments, avoid "php notice: undefined offset: 9" echo $array[$i].$array[$i+1] .'<br>'; }
Comments
Post a Comment