1

How could I use cURL to get back an array from this URL? http://module.game-monitor.com/67.202.102.136:27016/data/server.php

This is my code so far.

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://module.game-monitor.com/67.202.102.136:27016/data/server.php'); 
curl_setopt($ch, CURLOPT_HEADER, false); 
curl_setopt($ch, CURLOPT_NOBODY, false); // remove body 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);  
$head = curl_exec($ch); 
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); 
curl_close($ch); 
$head = unserialize($head);
$head = objectToArray($head);
$head["query_time"] = str_ireplace('ms', '', $head["query_time"]);
return $head;

1 Answer 1

2

Try just use PHP Type Casting (array) and remove the objectToArray function

$head = unserialize($head);
$head = (array) $head ;
var_dump($head);

Output

array
  'ip' => string '67.202.102.136' (length=14)
  'port' => string '27016' (length=5)
  'player' => int 0
  'maxplayer' => int 14
  'name' => string 'Another www.cogameservers.com CSGO Server' (length=41)
  'premium' => string '0' (length=1)
  'link' => string 'http://www.game-monitor.com/csgo2_GameServer/67.202.102.136:27016/Another_www.cogameservers.com_CSGO_Server.html' (length=112)
  'error' => int 0
  'query_time' => string '0ms' (length=3)
Sign up to request clarification or add additional context in comments.

3 Comments

When i paste the content of the webpage in a file and I run the linux command file to get infos, I get Solitaire Image Recorder format. Never seen this before. Anyone having more infos of the data representation of the string ? It's serialized in which format ?
Yes Baba, but how did you know to use unserialize() on this strange string ?
I did not save it just treated it has a string @sputnick

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.