1$x = 1;
2$length = count($data);
3
4foreach($data as $value){
5 echo"
6 <button class='btn";
7 if($x === 1){
8 echo " first";
9 }
10 else if($x === $length){
11 echo " last";
12 }
13 $x++;
14 echo"
15 '>$value->services_name</button>
16 ";
17 }