<?php
function removeDigits($string, array $digits) {
	return join(",", array_diff(explode(",", $string), $digits));
}

$str = "1,2,3,4,5,6";
$ignore = [1, 4, 5];

print_r(removeDigits($str, $ignore));
