strago Posted January 27, 2011 Share Posted January 27, 2011 <?php $user = $_GET['user']; $request_url ="http://www.domain.com/logs.shtml"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $request_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($ch); //THIS NEEDS CHANGED!!!!! $regex='|$user - (.*?) - $user|'; preg_match_all($regex,$result,$parts); $logs=$parts[1]; foreach($logs as $log){ echo "<B>".$log."</B><br>"; } curl_close($ch); ?> The logs file looks like username - log info - log info - log info - username For a URL like http-//www.domain.com/view-logs.php?user=strago I want it to spit out just the lines from the log file that got strago - log info - log info - log info - strago Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted January 27, 2011 Share Posted January 27, 2011 single quotes indicate a literal string, and there is no variable substitution. you'll need double-quotes, or concatenation $regex='|$user - (.*?) - $user|'; echo "regex: $regex"; output regex: '|$user - (.*?) - $user|' Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.