I got a string, built up like the following:
$string = 'HUB_NENNWERT_KATALOG:[0 TO 4.9],GREIFKRAFT_OEFFNEN_KATALOG:[2000 TO 5999],WERKSTUECKGEWICHT:[0 TO 14.9]';
The ints in this String can be different. So what I want is, check if a certain field is in the String, i.e. 'HUB_NENNWERT_KATALOG'. If returned true, I want to delete the whole substring inclusive the comma. So it would return a new String like this:
$string = 'GREIFKRAFT_OEFFNEN_KATALOG:[2000 TO 5999],WERKSTUECKGEWICHT:[0 TO 14.9]';
I know alle fields, that can occur, but not the values. How do I achieve this?
Hope it was described clear enough.
You could try:
You can use regular expression and replace the string found with empty string. Please look at this function:
preg_replace
Good luck!
If the structure of the string is always the same, maybe this could be another approach: