I have this string: $delims = ',^.;:\t' (which is used in a preg_replace() call).
I need two arrays .. one with those delimiters as the index ($delimCount), and another with those delimiters as the values ($delimiters).
The former will get values assigned from within a loop on the latter .. as such:
foreach ($delimiters as $delim) {
if( strpos($char, $delim) !== false) { // if the char is the delim ...
$delimCount[$delim]++; // ... increment
}
}
The way I have it now is messy, and I'd like to simply break that string into the two arrays ... but I'm getting tripped up on the \t delimiter (because it's the only one with two characters).
How can/should I handle that?
$delims = ",^.;:\t";instead?\tis one character then.$delimitersarray becomes an interpreted tab rather than '\t' which conflicts with a later need/usage ... maybe it's time for me to look at whether that later usage REALLY needs it as a string or not ... maybe I can just change that code and leave this problem with the simple/elegant solution proposed. Thanks-a-bunch. Let me know if you have any other thoughts.