如何限制内爆输出中的数组值

I have more than 10 values in my array.

I would like to separate it with comma.

So I used this code

echo implode(",", $array);

Can someone tell me how to limit the values.? I need only the first three values

slice the array first

$newArray = array_slice($array, 0, 3);
echo implode(',', $newArray);

Using array_slice :

 $slicedArray = array_slice($array, 0, 3);
 $input=implode(",", $slicedArray);