Replacing Tabs with Spaces : str_replace « String « PHP






Replacing Tabs with Spaces

 
<?php

$str = "
\tline
\t\tline
\t\t\tline
\t\t}
\t}
";

$replaced = str_replace("\t", '    ', $str);

echo "<pre>{$replaced}</pre>";
?>
  
  








Related examples in the same category

1.Replacing Substrings Using str_replace()
2.str_replace demo
3.str_replace() accepts arrays for all its arguments
4.str_replace() function searches for occurrence in string, replacing all instances with replacement.
5.str_replace.php
6.Using str_replace()
7.mixed str_replace ( mixed needle, mixed replace, mixed haystack [, int &count] )
8.case-sensitive?
9.Using template file
10.Switching tabs and spaces