Jump to content

Recommended Posts

Hope u guys can help me, I've got a problem:
I've got a form where I input some text, but I cann't make a space between lines (kind of paragraph); please help me, I really need this  :'(

Here is the code:

<?php
$link = "admin.php";
$linkShow = "Your info is saved";
$text = stripslashes($_POST["text"]);
$text_file = "text/homepage.txt";
$name_gax = file($text_file); //opens with array
$text_open = fopen($text_file, "w+"); //open message file with write
fputs($text_open, $text);
fclose($text_open);
echo "<a href='".$link."'>".$linkShow;
?>
Link to comment
https://forums.phpfreaks.com/topic/15692-urgent-help-needed/
Share on other sites

if only i could!

haha, it is a piece of code that I acquired some time ago, and uses regular expressions. Basically, it replaces any line returns from the textarea, with the paragraph and break tags that html uses.

eg

\r\n is one line break or return. so that should be <br />. two of them, equal a paragraph, which is <p></p>.

Pretty clever really. Did it do what you wanted?
Link to comment
https://forums.phpfreaks.com/topic/15692-urgent-help-needed/#findComment-64033
Share on other sites

You need to output the correct HTML tags along with the text.

For bolding:
(the old way)
[code]<?php echo '<b>' . $text . '</b>'; ?>[/code]
(the new way)
[code]<?php echo '<span style="font-weight:bold">' . $text . '</span>'; ?>[/code]

To create a link:
[code]<?php echo '<a href="http://url.goes.here/">' . $text . '</a>'; ?>[/code]

Ken
Link to comment
https://forums.phpfreaks.com/topic/15692-urgent-help-needed/#findComment-64077
Share on other sites

This is called BBCode. Search google for BBCode Inserter or something like that. It requires javascript. But to replace the BBCodes ie [ b]hello[/b] in to [b]hello[/b] will require the use of regular expressions. [url=http://www.phpfreaks.com/forums/index.php/topic,101566.msg402102.html#msg402102]Here[/url] is a very basic BBCode Parser, it parses bold, italic and underline BBCode.
Link to comment
https://forums.phpfreaks.com/topic/15692-urgent-help-needed/#findComment-64100
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.