Jump to content

One per line function?


EdRash

Recommended Posts

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

 

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]

 

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.

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]

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.