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 ParseTicketEmail($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 (wo***@world.com) bla";
print "$TicketEmail";
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