note 90515 modified in function.preg-replace-callback by danbrown

From: Date: Mon, 27 Apr 2009 15:52:50 +0000
Subject: note 90515 modified in function.preg-replace-callback by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-153846@lists.php.net to get a copy of this message
This is what i use to read log files and do dns lookups on the ip's from the file. <?php function resolve_logs($arr) { return gethostbyaddr($arr[0]); } $logent=file('yourlogfile'); $ipaddr = '/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/'; $logent = preg_replace_callback($ipaddr, resolve_logs, $logent); ?> --was-- This is what i use to read log files and do dns lookups on the ip's from the file. function resolve_logs($arr) { return gethostbyaddr($arr[0]); } $logent=file('yourlogfile'); $ipaddr = '/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/'; $logent = preg_replace_callback($ipaddr, resolve_logs, $logent); http://php.net/manual/en/function.preg-replace-callback.php

« previous php.notes (#153846) next »