fork(4) download
  1. <?php
  2. $string = "From: user1@somewhere.com This is just a test.. the original message was sent From: user2@abc.com";
  3.  
  4. $regExp = "/^From:\s*(\S+)/";
  5. $outputArray = array();
  6. if ( preg_match($regExp, $string, $outputArray) ) {
  7. print_r($outputArray[1]);
  8. }
Success #stdin #stdout 0.02s 24144KB
stdin
Standard input is empty
stdout
user1@somewhere.com