Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've built a small widget for my website
It has a couple of inputs, and a <textarea> among others.
Whenever someone inputs to the textarea it adds a tab at the begining
and changes every ' to \'
After a couple of times I save the same input,
I just get sentences that were

It's nice

to

It\\\\'s nice

the code for the Textrea:

         <textarea rows="5" cols="40" id="cat_<?php echo $i ?>_text" name="cat_<?php echo $i ?>_text">
        <?php echo $text ?>
        </textarea>

Any ideas?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Try stripslashes to remove the backslash.

echo stripslashes( $text );

This is going to replace one slash per slashes group only though, you should first reset all the contents that have multiple slashes.

I guess the tab at the beginning is due to the fact that you jump a line before echoing the text. Try this instead :

<textarea rows="5" cols="40" id="cat_<?php echo $i ?>_text" name="cat_<?php echo $i ?>_text"><?php echo stripslashes( $text ); ?></textarea>
share|improve this answer
    
worked like a charm, thanks :] –  Asaf Jul 14 '11 at 9:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.