Find the postion of the first comma. Find the postion of the last comma. If the email-position in the string is < firstcommaposn, replace email+comma+nextemail with nextemail, or remove all up to and including the first comma.
If the email-position in the string is > lastcommaposn, replace previousemail+comma+email with previousemail, or remove all after and including the last comma. else replace comma+email with comma Tim in Ireland ----- Original Message ----- From: "mac_fanatic14" <[EMAIL PROTECTED]> To: <[email protected]> Sent: Monday, October 31, 2005 11:40 PM Subject: [php-list] replacing a string in a larger string > ok, i want to remove an email from a list of emails stored in a text file. using str_replace i can > replace an email with nothing, but if the list is serated by commans, that would result in this: > > [EMAIL PROTECTED],,[EMAIL PROTECTED],[EMAIL PROTECTED] > > with no email between 2 commas. if i replace the email address with a comma on the end > with nothing, it wouldn't work for the last one. if i replace the email address with a comma at > the beginning, it wouldn't work for the first one. how can i avoid this or work around it? > thanks. > > > > > > > > > Community email addresses: > Post message: [email protected] > Subscribe: [EMAIL PROTECTED] > Unsubscribe: [EMAIL PROTECTED] > List owner: [EMAIL PROTECTED] > > Shortcut URL to this page: > http://groups.yahoo.com/group/php-list > Yahoo! Groups Links > > > > > > > ------------------------ Yahoo! Groups Sponsor --------------------~--> Most low income households are not online. Help bridge the digital divide today! http://us.click.yahoo.com/cd_AJB/QnQLAA/TtwFAA/HKFolB/TM --------------------------------------------------------------------~-> Community email addresses: Post message: [email protected] Subscribe: [EMAIL PROTECTED] Unsubscribe: [EMAIL PROTECTED] List owner: [EMAIL PROTECTED] Shortcut URL to this page: http://groups.yahoo.com/group/php-list Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/php-list/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
