Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
| Search | Today's Posts | Mark Forums Read
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 17th, 2004, 07:58 PM
Authorized User
 
Join Date: Jun 2003
Location: San Jose, CA, USA.
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default IP Address Regular Expression

OK, I have this wonderful regular expression that replaces IP addresses in a variable. The catch is that I want to replace the IP address with the same IP address, just with a link around it that you can click on for further information.

On the example below, I need to replace the $ip with the actual IP address from the expression.

$msg = ereg_replace("([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})", "<a href=\"script.php?$ip\">$ip</a>", $msg);

Can anyone help me?

----------
~cmiller
__________________
----------
~cmiller
 
Old December 4th, 2004, 02:17 PM
Authorized User
 
Join Date: Dec 2004
Location: , , United Kingdom.
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to colin.horne
Default

Okay, don't really understand what you need.

Do you mean you want to replace the variable $ip with the IP address of the person who is looking at the site?

If so, use $_SERVER['REMOTE_ADDR'].

Cheers

--
Please contact me at:
Colin (dot) Horne (at) gmail (dot) com




Similar Threads
Thread Thread Starter Forum Replies Last Post
Help me i must Get IP Address pla_2 C# 2005 2 October 12th, 2006 07:51 AM
IP Address sumanghosh Classic ASP Basics 1 April 7th, 2006 11:24 AM
How to get IP address shankhan Classic ASP Databases 6 March 10th, 2005 04:18 PM
Retreiving IP address & gateway address sjangit VBScript 0 February 3rd, 2004 02:02 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.