doubledee Posted April 25, 2011 Share Posted April 25, 2011 I have a Description field that gets sent to my Payment Gateway which can be put in an e-mail to my customer after a successful purchase. Is it possible to have multiple lines and line-breaks in one Array Value?? For example... $post_values = array( "x_description" => "Fuzzy Sweater Girls Medium Long-Sleeve $75", Debbie Quote Link to comment https://forums.phpfreaks.com/topic/234630-multiple-lines-in-array-value/ Share on other sites More sharing options...
wildteen88 Posted April 25, 2011 Share Posted April 25, 2011 Yes that is fine. That is perfectly valid syntax. Quote Link to comment https://forums.phpfreaks.com/topic/234630-multiple-lines-in-array-value/#findComment-1205815 Share on other sites More sharing options...
fugix Posted April 25, 2011 Share Posted April 25, 2011 Do you want to store it that way or show it like that? Quote Link to comment https://forums.phpfreaks.com/topic/234630-multiple-lines-in-array-value/#findComment-1205841 Share on other sites More sharing options...
doubledee Posted April 25, 2011 Author Share Posted April 25, 2011 Do you want to store it that way or show it like that? Good catch!! The answer is "Yes!" I would like to do both, although my original question was meant to ask "How can I insert carriage returns in the Array Value so when it is inserted into the Confirmation Email the customer sees the results on several lines?" Confirmation Email This is to confirm that you just bought: Fuzzy Sweater Girls Medium Long-Sleeve $75 Thanks, Debbie Quote Link to comment https://forums.phpfreaks.com/topic/234630-multiple-lines-in-array-value/#findComment-1205899 Share on other sites More sharing options...
fugix Posted April 25, 2011 Share Posted April 25, 2011 storing them like that isnt really important..so i would store them like a normal array...to display them like that I would use a foreach loop foreach($post_values as $array_values) { echo $array_values . "<br />"; } something like that Quote Link to comment https://forums.phpfreaks.com/topic/234630-multiple-lines-in-array-value/#findComment-1205902 Share on other sites More sharing options...
doubledee Posted April 25, 2011 Author Share Posted April 25, 2011 storing them like that isnt really important..so i would store them like a normal array...to display them like that I would use a foreach loop foreach($post_values as $array_values) { echo $array_values . "<br />"; } something like that You're missing my point... The Payment Gateway gives me ONE FIELD to insert Comments, and I want it printed out on multiple lines like mentioned above. Unfortunately have a separate field for each thing isn't possible. $post_values = array( "x_description" => "Fuzzy Sweater Girls Medium Long-Sleeve $75", Debbie Quote Link to comment https://forums.phpfreaks.com/topic/234630-multiple-lines-in-array-value/#findComment-1205909 Share on other sites More sharing options...
Pikachu2000 Posted April 25, 2011 Share Posted April 25, 2011 You mean like this? $post_values = array( "x_description" => "Fuzzy Sweater\n Girls\n Medium\n Long-Sleeve\n $75"); echo nl2br($post_values[0]); Quote Link to comment https://forums.phpfreaks.com/topic/234630-multiple-lines-in-array-value/#findComment-1205915 Share on other sites More sharing options...
doubledee Posted April 25, 2011 Author Share Posted April 25, 2011 You mean like this? $post_values = array( "x_description" => "Fuzzy Sweater\n Girls\n Medium\n Long-Sleeve\n $75"); echo nl2br($post_values[0]); That is what I was thinking, but it looks like they strip out the "\n" :-\ Debbie Quote Link to comment https://forums.phpfreaks.com/topic/234630-multiple-lines-in-array-value/#findComment-1205918 Share on other sites More sharing options...
Pikachu2000 Posted April 25, 2011 Share Posted April 25, 2011 If it's just a comment field, can you simply use a <br>? Quote Link to comment https://forums.phpfreaks.com/topic/234630-multiple-lines-in-array-value/#findComment-1205920 Share on other sites More sharing options...
doubledee Posted April 25, 2011 Author Share Posted April 25, 2011 If it's just a comment field, can you simply use a <br>? I'll try, but wouldn't it be safer if it was encoded or whatever so the HTML doesn't get stripped as well? If so, how would I convert <br> to whatever? Debbie Quote Link to comment https://forums.phpfreaks.com/topic/234630-multiple-lines-in-array-value/#findComment-1205921 Share on other sites More sharing options...
Pikachu2000 Posted April 25, 2011 Share Posted April 25, 2011 htmlspecialchars or htmlentities Quote Link to comment https://forums.phpfreaks.com/topic/234630-multiple-lines-in-array-value/#findComment-1205925 Share on other sites More sharing options...
doubledee Posted April 25, 2011 Author Share Posted April 25, 2011 If it's just a comment field, can you simply use a <br>? I tried both combinations and it just prints <br> in my description. "x_description" => "A quick brown fox jumps over the lazy dog. <br> A quick brown fox jumps over the lazy dog. <br> A quick brown fox jumps over the lazy dog.", The output keeps coming up... A quick brown fox jumps over the lazy dog. <br> A quick brown fox jumps over the lazy dog. <br> A quick brown fox jumps over the lazy dog. Guess I'll just have to live with a long, continuous line that wraps. :-\ Debbie Quote Link to comment https://forums.phpfreaks.com/topic/234630-multiple-lines-in-array-value/#findComment-1205932 Share on other sites More sharing options...
Pikachu2000 Posted April 25, 2011 Share Posted April 25, 2011 Where does the email originate? From your server, or the payment processor's server? Quote Link to comment https://forums.phpfreaks.com/topic/234630-multiple-lines-in-array-value/#findComment-1205935 Share on other sites More sharing options...
doubledee Posted April 25, 2011 Author Share Posted April 25, 2011 Where does the email originate? From your server, or the payment processor's server? From Authorize.net I pass them: "x_description" => "This is a description..." and they return it and other pre-determined data is a pre-made Customer Receipt which they send to the customer directly. Debbie Quote Link to comment https://forums.phpfreaks.com/topic/234630-multiple-lines-in-array-value/#findComment-1205941 Share on other sites More sharing options...
Pikachu2000 Posted April 25, 2011 Share Posted April 25, 2011 That's what I kind of thought. You'd need to check their specs to see how to insert a line break, or if it's even possible. Quote Link to comment https://forums.phpfreaks.com/topic/234630-multiple-lines-in-array-value/#findComment-1205948 Share on other sites More sharing options...
doubledee Posted April 25, 2011 Author Share Posted April 25, 2011 That's what I kind of thought. You'd need to check their specs to see how to insert a line break, or if it's even possible. I'll probably just cope. This is just a stop-gap until I can build my own e-mails. Thanks, Debbie Quote Link to comment https://forums.phpfreaks.com/topic/234630-multiple-lines-in-array-value/#findComment-1205956 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.