View Full Version : Receive variable from external source code

09-23-2007, 01:37 PM
I need a variable, the value of which is in the source code of a separate website on a separate server. What's the best way to get that variable into my code? For example:

source code of http://notmyserver.com is

value is 1234

and a variable on a server which is mine contains the value '1234'.

I don't need to strictly use PHP, any language will do. Thanks!

09-23-2007, 05:44 PM
Grab the contents of the page and use regular expressions to extract your value.

$html = file_get_contents('http://otherserver.com');
$matches = array();
$ret = preg_match('/pattern/', $html, $matches);
// $matches would have your value

This isn't very efficient if you're doing it on every pageload. You should have it on a timer of some sort instead.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum