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?
How I would handle your
\tdelimiterOutput of $delimiters
As far as an array with the delimiters as an index
Output of $delimCount
Hope this helps.