Hello all;
When padding a string for display in a CLI script, I’ve found that escape sequences seem to confuse the mb_str_pad() function.
Specifically, say I want a list of results for the word time: pretend the results are:
Now is the time for all good men Record A
What time is the party? Record B
The bus was actually on time yesterday Record C
I’d like to display results in a list with padded columns, highlighting the match with color, something like
Now is the **YLW** time **WHT** for all good men
What **YLW** time **WHT** is the party?
The bus was actually on **YLW** time **WHT** yesterday
where YLW and WHT are the escape sequences for yellow and white foregrounds respectively. The padding works fine when I omit the escape sequences, but the columns are truncated when they are included:
Now is the time for all good men Record A
What time is the party? Record B
The bus was actually on time yesterday Record C
To confuse matters, a var_dump() says the strings are the expected length (120). But copy/paste them from the terminal to mousepad or some such and they aren’t; they’re 100.
PHP version 8.3.6, xubuntu 24.04
Any thoughts?