Reputation: 15949
For readability reasons , I have a code that looks like this :
<textarea cols="50" rows="5" id="k99_brsa_settings[brsa_keep_settings_exp]" name="k99_brsa_settings[brsa_keep_settings_exp]" />
<?php echo $export; ?>
</textarea>
I do not know how to represent / display tabs
here , but it is actually like so :
[TAB][TAB][TAB][TAB]<textarea cols="50" rows="5" id="k99_brsa_settings[brsa_keep_settings_exp]" name="k99_brsa_settings[brsa_keep_settings_exp]" />
[TAB][TAB][TAB][TAB][TAB]<?php echo $export; ?>
[TAB][TAB][TAB][TAB]</textarea>
or better yet with an image ( code editor ) :
The problem is , that those tabs appear in the Output like so :
and since those are DB entries, when I save , it actually CHANGES the entry (adds tabs and spaces )
I know that when I change the code to a one liner
:
<textarea cols="50" rows="5" id="k99_brsa_settings[brsa_keep_settings_exp]" name="k99_brsa_settings[brsa_keep_settings_exp]" /><?php echo $export; ?></textarea>
(image from code editor below )
...there is no problem and no tabs / spaces .
Is there any way to keep the tabs for readability AND eliminating those output tabs and spaces ? Does the <textarea>
TAGS always HAVE to end after the output without spaces
Upvotes: 1
Views: 2863
Reputation: 956
One alternative is to shorten your php a little by replacing <?php echo $export; ?>
with <?= $export ?>
. It may make you feel better about putting it all on one line.
I know people don't suggest the use of shorttags, but per http://php.net/manual/en/language.basic-syntax.phpmode.php, the short tag syntax will always be recognized by php 5.4 and up.
Upvotes: 0
Reputation: 6639
You could try and trim extra whitespaces down to a single whitespace I guess. Or change your markup to remove the tabs.
<?php
// This will replace any double whitespace with a single whitespace
$result = str_replace(' ', ' ', $result);
?>
Upvotes: 0
Reputation: 191749
You can still keep it on multiple lines with
<textarea ...><?php
?></textarea>
Alternatively you could do:
<?php
echo "<textarea line1>"
. $export
. "</textarea>";
?>
Upvotes: 2