Place a char before every char
Hi,
I'm trying to do something like this: abcde fgh to 1a1b1c1d1e1 1f1h1g1h Any ideas? Maybe using regex or breaking the string? Thanks! |
Re: Place a char before every char
I'm sure there's better ways than the following but with understanding the basic functions and logic you can become creative with many ways to a solution.
PHP Code:
PHP Code:
|
Re: Place a char before every char
If you're going to loop over all the characters of the input, you don't want to Format every time. You only need to do two character assignments as you go along: out[i * 2] = separator and out[i * 2 + 1] = input[i].
Also, Format is able to use the same buffer for both input and output. |
All times are GMT -4. The time now is 21:53. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.