Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Text to Image Previewer script - linebreak help
Old 06-15-2010, 02:59 PM Text to Image Previewer script - linebreak help
Junior Talker

Posts: 1
Name: Derek
Trades: 0
Hello. My name is Derek. I'm new to the forums and thought this place is the right venue to ask for some help. I have recently downloaded this free script:

lightphpscripts.com/?s=Free-PHP-Ajax-Text-To-Image-PreViewer

Everything is working fine, however, when entering text and hitting enter for a new line does not render in the image preview. Can anyone look at this and let me know how to make the linebreak work? There's also a demo on the site I posted so you can see what I'm talking about when trying to make it render a new line. Any help would be much appreciated. This is the only script I could find to put on my website. If anyone else knows of a similar script that works with linebreaks, I'd very much appreciate it. Thanks in advance to my knowledge peers!

Derek

Last edited by chrishirst; 06-15-2010 at 03:41 PM..
dzkidz is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-15-2010, 05:35 PM Re: Text to Image Previewer script - linebreak help
Physicsguy's Avatar
404 - Title not found

Posts: 920
Name: Scott Kaye
Location: Ontario
Trades: 0
As in this?

Code:
Line 1

Line 2
Line 3
But it shows up as Line 1Line 2Line 3?

Just replace your enters with a <br />, standing for Line Break , hope that's what you need

PS Welcome to Webmaster-talk! I hope you found what you were looking for!

OR If you're making a user input box where they can type line breaks into a box, or som3ehow get this script below to work for everything, go for it. However, it is a good idea to just use <br />s regularly.

Code:
<?php
$text  = "You should eat fruits, vegetables, and fiber every day.";
$from = array("\n");
$to   = array("<br />");
echo str_replace($from, $to, $text);
?>
As a side note, you can change the $variable names (the things with the dollar signs) to whatever you want, 'text', 'to', and 'from' aren't key, you can make them bob, joe, and sally :P

Now what that script does it take everything from $from and replace it with $to, using PHP's built-in function called 'str_replace'. '\n' Is a 'newline', meaning every time a user enters a
new line, it will actually just render a \n in the box. You don't actually ever see this in the source or in the box itself, but it's there
__________________
Check out my
Please login or register to view this content. Registration is FREE
or my
Please login or register to view this content. Registration is FREE
!

Last edited by Physicsguy; 06-15-2010 at 05:40 PM..
Physicsguy is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Text to Image Previewer script - linebreak help
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.16252 seconds with 12 queries