From Fedora Project Wiki
#!/usr/bin/php
<?
define('TAB_WIDTH', 5);
foreach(file('php://stdin') as $l){
preg_match_all('/\t+/', $l, $m, PREG_OFFSET_CAPTURE);
foreach($m[0] as $mm){
$l = str_replace(
$mm[0]
,str_repeat(' ', (TAB_WIDTH - ($mm[1] % TAB_WIDTH)) + ( TAB_WIDTH * ( strlen($mm[0]) - 1 ) ))
, $l
);
}
echo $l;
}
?>