PHP: extract email and name from data file

Posted by pi-2r on Stack Overflow See other posts from Stack Overflow or by pi-2r
Published on 2012-11-21T16:57:52Z Indexed on 2012/11/21 16:59 UTC
Read the original article Hit count: 153

Filed under:
|

I need to extract the name and the e-mail from one data file. the file contains more than 500 lines and I want to extract this two informations almost all the data. I would like to use preg_match_all, but my function doesn't work ...

  $chaine =
"  -----------------
11/21/12 16:06:54 tcp static-qvn-qvt-127041
MAIL [email protected]
NAME tata1
 -----------------
11/21/12 16:06:54 tcp static-qvn-qvt-127041
MAIL [email protected]
NAME tata2
 *  -----------------
11/21/12 16:06:54 tcp static-qvn-qvt-127041
MAIL [email protected]
NAME tata3
";

//$chaine =" #76:50#89:1#86:50#49:1#84:22";
$motif="/MAIL([a-z]{2,4}+)NAME([a-z]{2,4}+)/";
preg_match_all($motif,$chaine,$out);
$nb=count($out[0]);
for($i=0;$i<$nb;$i++)
{
    echo $out[0][$i].'<br/>';
}

© Stack Overflow or respective owner

Related posts about php

Related posts about regex