Jump to content

[SOLVED] Turning Something Into an Array


JSHINER

Recommended Posts

I have this:

 

if(isset($_POST['send'])) {
echo str_replace("###", ", ", $_POST['to']), '<br>';
echo $_POST['subject'], '<br>';
echo $_POST['message'], '<br>';
echo $_POST['user_id'];
}

 

Which works fine. But the $_POST['to'] comes over as "[email protected], [email protected], [email protected]" - how can I turn that into an array and have it run a foreach so it displays the subject, message, user_id individually for each email sent.

 

So would echo:

 

[email protected]

Subject

Message

UserId

 

[email protected]

Subject

Message

UserId

 

etc...

Link to comment
https://forums.phpfreaks.com/topic/122584-solved-turning-something-into-an-array/
Share on other sites

$_POST['send'] = TRUE;
$_POST['to'] = '[email protected]###[email protected]';
$_POST['subject'] = 'subject';
$_POST['message'] = 'message';
$_POST['user_id'] = 'userid';

if(isset($_POST['send']))
foreach( explode('###', $_POST['to']) as $email ) {
	echo $email. '<br>';
	echo $_POST['subject']. '<br>';
	echo $_POST['message']. '<br>';
	echo $_POST['user_id']. '<br><br>';
}

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.