D
D
Dmitry Krylov2019-04-21 19:46:38
PHP
Dmitry Krylov, 2019-04-21 19:46:38

How to parse part of the results from this page?

Good afternoon. Tell me the parser code that would help parse data from this file?
https://www.hetzner.com/a_hz_serverboerse/live_dat...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
Gip, 2019-04-22
@Giperoglif

and if you go to some https://jsonutils.com/
then in general you can stir up this:

class MinMaxValues
{
    public $minPrice; //int
    public $maxPrice; //double
    public $minRam; //int
    public $maxRam; //int
    public $minHDDSize; //int
    public $maxHDDSize; //int
    public $minHDDCount; //int
    public $maxHDDCount; //int
    public $minBenchmark; //int
    public $maxBenchmark; //int
}

class Server
{
    public $key; //int
    public $name; //String
    public $description; //array(String)
    public $cpu; //String
    public $cpu_benchmark; //int
    public $cpu_count; //int
    public $is_highio; //boolean
    public $is_ecc; //boolean
    public $traffic; //String
    public $dist; //array(String)
    public $bandwith; //int
    public $ram; //int
    public $price; //String
    public $price_v; //String
    public $ram_hr; //String
    public $setup_price; //String
    public $hdd_size; //int
    public $hdd_count; //int
    public $hdd_hr; //String
    public $fixed_price; //boolean
    public $next_reduce; //int
    public $next_reduce_hr; //String
    public $datacenter; //array(String)
    public $specials; //array(String)
    public $specialHdd; //String
    public $freetext; //String
}

class MyClass
{
    public $hash; //String
    public $minMaxValues; //MinMaxValues
    public $server; //array(Server)
}

not to suffer with undescribed Std.

D
DanKud, 2019-04-21
@DanKud

$json = file_get_contents('https://www.hetzner.com/a_hz_serverboerse/live_data.json');
$arr = json_decode($json, true);
print_r($arr); /* на выходе получаете обычный массив */

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question