if first php
snippet in php

if first php

user499

$x = 1;
$length = count($data); 

foreach($data as $value){
        echo"
            <button class='btn";
                if($x === 1){
                    echo " first";
                }
                else if($x === $length){
                    echo " last"; 
                }
                $x++;
        echo"
           '>$value->services_name</button>
        ";
    }