I need to parse a string with an embedded email address.
The string always has the format NAME (name@domain) SOMETEXT.
What I need to get is the email address as name@domain.
I came up with this (I know it's broken, but it's a first start):
<?php
function ParseTicketEmai l($ticket)
{
global $TicketEmail;
for ($i=0; $i< strlen($ticket) ; $i++){
//we need to pass everything between ( and ) to $TicketEmail nothing else
do {
$ticket[$i] = $discarded;
} while ($ticket[$i] != '(');
while ($ticket[$i] != ')'){
$TicketEmail = $TicketEmail . $ticket[$i];
}
}
return $TicketEmail;
}
$ticket = "hello (world@world.co m) bla";
print "$TicketEma il";
print "$discarded ";
?>
But that doesn't return anything for either $TicketEmail or $discarded.
So
a: why doesn't it return anything for either string? (It's too early in the morning here)
b: does anyone have such a function anywhere for me to check out for how to do it?
/M.
--
Martin Skjöldebrand
Family site: http://www.skjoldebrand.org
"Art" site: http://martoni.deviantart.com
Public key available at: http://wwwkeys.pgp.net
The string always has the format NAME (name@domain) SOMETEXT.
What I need to get is the email address as name@domain.
I came up with this (I know it's broken, but it's a first start):
<?php
function ParseTicketEmai l($ticket)
{
global $TicketEmail;
for ($i=0; $i< strlen($ticket) ; $i++){
//we need to pass everything between ( and ) to $TicketEmail nothing else
do {
$ticket[$i] = $discarded;
} while ($ticket[$i] != '(');
while ($ticket[$i] != ')'){
$TicketEmail = $TicketEmail . $ticket[$i];
}
}
return $TicketEmail;
}
$ticket = "hello (world@world.co m) bla";
print "$TicketEma il";
print "$discarded ";
?>
But that doesn't return anything for either $TicketEmail or $discarded.
So
a: why doesn't it return anything for either string? (It's too early in the morning here)
b: does anyone have such a function anywhere for me to check out for how to do it?
/M.
--
Martin Skjöldebrand
Family site: http://www.skjoldebrand.org
"Art" site: http://martoni.deviantart.com
Public key available at: http://wwwkeys.pgp.net
Comment