Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Aug 2005
    Posts
    70
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Receive variable from external source code

    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

    <html>
    hi!
    value is 1234
    </html>

    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!

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,642
    Thanks
    2
    Thanked 405 Times in 397 Posts
    Grab the contents of the page and use regular expressions to extract your value.
    PHP Code:
    $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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •