Page 1 of 1

tab character to whitespaces

Posted: Wed Jan 10, 2007 4:08 pm
by julian_lp
I need to keep the format after replacing tabs to withespaces...

Is there a recommended way to replace the tab character with white spaces in order to save the original format ?

Rephrasing the question would be... how many spaces does a Tab character involves? I guess it is not always the same number though...

Re: tab character to whitespaces

Posted: Wed Jan 10, 2007 5:47 pm
by volka
julian_lp wrote:I guess it is not always the same number though...
That is correct and therefore the answer to your question is: it depends ;)

Posted: Wed Jan 10, 2007 5:52 pm
by pickle
Ya, it depends, but I think in most cases it's 4. I've only ever seen 4 & 2 as defaults in programs.

Probably the easiest way to do it would be:

Code: Select all

$new_format = str_replace("\t",'    ',$old_format);