Jump to content

Replying on a message system


Shadowing

Recommended Posts

On most website messaging systems when you hit reply on a message it takes you to the compose screen with the reply message auto filled in.

 

Im using a Session to achieved this.

 

My question is how do they make it so each line of the reply has arrows like this  > message >>

 

so it seperates the reply from what the person is about to type

 

This has me clueless

Link to comment
Share on other sites

Well, what do you mean by "each line"? I can type a whole paragraph and it is only one line, but it will display on multiple lines based upon how wide the content frame is to display it. Usually when text is "quoted" in the manner you describe (such as in an email) the content has hard breaks added to it. So, assuming you want to add hard breaks, you need to decide how many characters there should be per line.

 

So, you can use wordwrap() to split the strings into lines. Then explode() the content into an array based upon the line breaks, loop through each line to add the preface characters (i.e. "> message >>"), then lastly implode() the content back into a string with line breaks.

 

Assuming $input holds the text to be quoted:

//Break each line by no more than 60 characters
//And explode itno an array by each line
$lines = explode("\n", wordwrap($input, 60));
//Add the preface text to each line
foreach($lines as &$line)
{
    $line = "> message >> {$line}";
}
//Implode the results back into a string variable to be output
$output = implode("\n", $lines);

Link to comment
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.