ironside82 Posted December 23, 2007 Share Posted December 23, 2007 Ok heres the scene, I have a private message system that I need to implement a multiple recipients feature to extract individual member names from one entry which the user will divide up using commas when they press submit: eg:- username1,username2,username3,username4 this is what will be what is submitted from the form I'm trying to work out the loop that will use the split() function to work out how many usernames have been submitted in the form, split them up, and then send to my messages sql database along with the content of the actual private message itself. I just can get my head around it. I'm sure it relatively simple. If any of you guys could point me in the right direction that would be a great help Thanks in advance James Quote Link to comment https://forums.phpfreaks.com/topic/82946-splitting-text-field/ Share on other sites More sharing options...
phpSensei Posted December 23, 2007 Share Posted December 23, 2007 <?php $post_field = $_POST['usernames']; $post_field = explode(",",$post_field); echo $post_field[0]; // member1 echo $post_field[1]; // member2 echo $post_field[2]; // member3 ?> Quote Link to comment https://forums.phpfreaks.com/topic/82946-splitting-text-field/#findComment-421856 Share on other sites More sharing options...
papaface Posted December 23, 2007 Share Posted December 23, 2007 $str = "papa_face,ironside82"; $username = explode(",",$str); foreach ($username as $key => $value) { //do something with each username ($value) } Quote Link to comment https://forums.phpfreaks.com/topic/82946-splitting-text-field/#findComment-421857 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.