seperating text

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
m2babaey
Forum Contributor
Posts: 364
Joined: Sun May 20, 2007 9:26 am

seperating text

Post by m2babaey »

Hi
assuming the following records:
field1(name): m2babaey
filed2(hisemailids): m2babaey1@yahoo.com, m2babaey2@yahoo.com, m2babaey3@yahoo.com

now can we do anything to display:

m2babaey: m2babaey1@yahoo.com
m2babaey: m2babaey2@yahoo.com
m2babaey: m2babaey3@yahoo.com
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Post by Zoxive »

explode() maybe be of interest.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Did you post the actual data? Post an actual record.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Something tells me this should be normalized...
m2babaey
Forum Contributor
Posts: 364
Joined: Sun May 20, 2007 9:26 am

Post by m2babaey »

of course m2babaey123 are not actual. but field 2 will be some email addresses posted from a textarea and I'd like to list them the way i said :roll:
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

m2babaey wrote:of course m2babaey123 are not actual. but field 2 will be some email addresses posted from a textarea and I'd like to list them the way i said :roll:
Well if it's all in one field, you'll have to process it through PHP, which isn't even hard in the least.

Code: Select all

$emails = explode(',', $result->field2);
foreach($emails as $email)
{
    echo $result->field1 . ': ' . trim($email) . "<br />\n";
}
Post Reply