EdRash Posted March 19, 2009 Share Posted March 19, 2009 Please Help! I have invite function on my site, that allows send multiple invite emails separated by commas: $invite_emails = implode(",", array_slice(explode(",", $invite_emails) I want to change function so, that emails was separated by line (one email per line). Link to comment https://forums.phpfreaks.com/topic/150118-one-per-line-function/ Share on other sites More sharing options...
Renlok Posted March 19, 2009 Share Posted March 19, 2009 change "," to "\n" or "<br>" Link to comment https://forums.phpfreaks.com/topic/150118-one-per-line-function/#findComment-788366 Share on other sites More sharing options...
EdRash Posted March 19, 2009 Author Share Posted March 19, 2009 It's dosn't work, if: $invite_emails = implode("\n", array_slice(explode("\n", $invite_emails) or $invite_emails = implode("<br>", array_slice(explode("<br>", $invite_emails) send only one email. if: $invite_emails = implode("\n"\n array_slice(explode("\n"\n $invite_emails) or $invite_emails = implode("<br>"<br> array_slice(explode("<br>"<br> $invite_emails) give syntax error Link to comment https://forums.phpfreaks.com/topic/150118-one-per-line-function/#findComment-788372 Share on other sites More sharing options...
pkSML Posted March 19, 2009 Share Posted March 19, 2009 Have you tried preg_replace? You are wanting the output to be a multi-line string, correct? Link to comment https://forums.phpfreaks.com/topic/150118-one-per-line-function/#findComment-788392 Share on other sites More sharing options...
EdRash Posted March 19, 2009 Author Share Posted March 19, 2009 Output allredy multiple, i want that multiple email input was separated by line and/or paragraph. I can try preg_replace, but where to place it? Link to comment https://forums.phpfreaks.com/topic/150118-one-per-line-function/#findComment-788402 Share on other sites More sharing options...
pkSML Posted March 19, 2009 Share Posted March 19, 2009 Here are the arguments: mixed preg_replace ( mixed pattern, mixed replacement, mixed subject [, int limit [, int &count]] ) So, here's how I'd do it. <?php $invite_emails = '[email protected], [email protected], [email protected],[email protected]'; $search = array('@,\s@', '@,@'); $replace = array("\n", "\n"); $invite_emails = preg_replace($search, $replace, $invite_emails); echo "<PRE>" . $invite_emails . "</PRE>"; ?> This script takes this: [email protected], [email protected], [email protected],[email protected] and makes it this: [email protected] [email protected] [email protected] [email protected] Link to comment https://forums.phpfreaks.com/topic/150118-one-per-line-function/#findComment-788407 Share on other sites More sharing options...
pkSML Posted March 19, 2009 Share Posted March 19, 2009 Here are the arguments: mixed preg_replace ( mixed pattern, mixed replacement, mixed subject [, int limit [, int &count]] ) So, here's how I'd do it. <?php $invite_emails = '[email protected], [email protected], [email protected],[email protected]'; $search = array('@,\s@', '@,@'); $replace = array("\n", "\n"); $invite_emails = preg_replace($search, $replace, $invite_emails); echo "<PRE>" . $invite_emails . "</PRE>"; ?> This script takes this: [email protected], [email protected], [email protected],[email protected] and makes it this: [email protected] [email protected] [email protected] [email protected] PS If you need more help, put an example of what $invite_emails looks like in [ code ] tags. Link to comment https://forums.phpfreaks.com/topic/150118-one-per-line-function/#findComment-788422 Share on other sites More sharing options...
EdRash Posted March 19, 2009 Author Share Posted March 19, 2009 It's not exacly what I want. The current code is: // CHECK FOR NO INVITE EMAILS if(trim($invite_emails) == "") { $is_error = 1073; } // SEND INVITATION IF NO ERROR if($is_error == 0) { $invite_emails = implode(",", array_slice(explode(",", $invite_emails), 0, 100)); I want that script take this and send as is: [email protected] [email protected] [email protected] [email protected] Link to comment https://forums.phpfreaks.com/topic/150118-one-per-line-function/#findComment-788452 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.