What are common syntax errors to watch out for when implementing Bubblesort in PHP?

One common syntax error to watch out for when implementing Bubblesort in PHP is forgetting to properly close your control structures like loops or if statements with curly braces. Make sure to always include opening and closing curly braces for each control structure to avoid syntax errors.

function bubbleSort($arr) {
    $n = count($arr);
    for($i = 0; $i < $n-1; $i++) {
        for($j = 0; $j < $n-$i-1; $j++) {
            if($arr[$j] > $arr[$j+1]) {
                $temp = $arr[$j];
                $arr[$j] = $arr[$j+1];
                $arr[$j+1] = $temp;
            }
        }
    }
    return $arr;
}