If I have a line with identifiers
$myIDs = '22,34,445,67889,23';
and Iām assigned a value, how to remove it from the string, if I know for sure what is it in the string?
$removeID = '445';
Am I using user preg_replace or is there a better method? For example, if it is in the middle of the line, and I delete only the value, I get two commas, and then I need to replace them with one comma?
preg_replace($removeID, '', $myIDs);
UPDATE: These are all great deals. However, I just thought of one potential problem. This probably needs to be treated as an array instead of a regular expression. Which my line looks like this:
$myIDs = '2312,23,234234';
and identifier for deletion
$removeID = '23';
Too many potential matches ...
santa source share