Shadowing Posted December 28, 2011 Share Posted December 28, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/253951-replying-on-a-message-system/ Share on other sites More sharing options...
Psycho Posted December 28, 2011 Share Posted December 28, 2011 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); Quote Link to comment https://forums.phpfreaks.com/topic/253951-replying-on-a-message-system/#findComment-1301867 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.