<?php $tests = [ ", One ,, ,,", ", Two , Three", "Four, Five ", " Six,Seven, ", " ,Eight ,Nine , , , , Ten ,", ]; foreach ($tests as $test) { var_export( preg_replace('/[, ]+/', ', ', trim($test, ', ')) ); echo "\n"; }
You have javascript disabled. You will not be able to edit any code.