- Forums
- PHP
- How To Remove Tabs spaces From String In Php Code
This Page Contains information about How To Remove Tabs spaces From String In Php Code By wallpaperama in category PHP with 2 Replies. [1236], Last Updated: Sat May 18, 2024
wallpaperama
Fri Jan 02, 2009
2 Comments
8191 Visits
$string = str_replace("\\t",'',$string);
if you want to know how you can remove tabs from a strin in php.
to remove the tabs you simple use the str_replace() function in php
here i wrote a simple php file you can create your own so you can see it in action:
open your text editor like notepad, copy and paste this code and save it as wallpaperama.php then upload to your php site and run it with your browser, then you will see how i removed the tabs. removing tabs is easy. try it.
<?
$string = 'line 1: one tabs: |-
line 2: two tabs |-
line 3: some text with 3 tabs in between
line 4: line 4 has no tabs';
echo 'Original $string: <br><textarea cols="40" rows="7">'.$string.'</textarea><br>';
$string = str_replace("\\t",'',$string);
echo '<br>$string without tabs: <br><textarea cols="40" rows="7">'.$string.'</textarea>';
?>
hope that helps