Comma quibbling: Difference between revisions

Content added Content deleted
(→‎{{header|PHP}}: Don't modify the array; eliminate separate 2-item case (which the 3+-item case already handled); refactor to use switch instead of if/then)
m (→‎{{header|PHP}}: fix formatting.)
Line 3,436: Line 3,436:


default:
default:
$left = implode(', ', array_slice($arr, 0, -1));
$left = implode(', ', array_slice($arr, 0, -1));
$right = array_slice($arr, -1)[0];
$right = array_slice($arr, -1)[0];
return "{{$left} and {$right}}";
return "{{$left} and {$right}}";


}
}