Jump to content

Proper way to echo this... (Help?)


EsOne

Recommended Posts

I decided to ask this question here.

 

I have a code that scrapes a page for info, then in turn echos something when a certain data compnent is found in the scrape.

 

<html>
<head><?php
$data = file_get_contents('http://www.gaiaonline.com/chat/gsi/index.php?v=json&m=[[6500%2C[1]]%2C[6510%2C[%225175269%22%2C0%2C1]]%2C[6511%2C[%225175269%22%2C0]]%2C[6512%2C[%225175269%22%2C0]]%2C[107%2C[%22null%22]]]&X=1260296981');
$regex = '/"state":"(.+?)","player_count"/';
preg_match($regex,$data,$match);
var_dump($match);

if ($match[1] == 'open') {
   echo 'Glowing';
}
elseif ($match[1] != 'open')
{
echo "Not Glowing";
}


?></head>
<body>
</body>
</html>

 

This is my code so far.

 

The output of this is:

 

array(0) { } Not Glowing 

 

How do I make it echo just the "Not Glowing", or when the correct data is found on the page I am scraping to say JUST "Glowing", instead of having the arrays showing?

Link to comment
Share on other sites

:'(

 

Sorry, kind of new to PHP.

Care to explain exactly what var_dump does?

 

Also, what would be the proper way to loop this (ex. elseif loop until the $match == 'open')?

I know I cannot have it constantly looping, but what would be the proper way to make it loop and re-check the data every 5 minutes or so?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.