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 Link to comment https://forums.phpfreaks.com/topic/225890-geting-the-regular-expression-from-both-the-url-and-the-script/ 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|' Link to comment https://forums.phpfreaks.com/topic/225890-geting-the-regular-expression-from-both-the-url-and-the-script/#findComment-1166218 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.