@MadHowradBot

Как вывести id server из массива?

Вот что я получаю
{
  "server": {
    "id": 21018870,
    "name": "gfdgs",
    "status": "initializing",
    "created": "2022-06-03T21:57:06+00:00",
    "public_net": {
      "ipv4": {
        "ip": "49.12.222.249",
        "blocked": false,
        "dns_ptr": "static.249.222.12.49.clients.your-server.de",
        "id": 7834446
      },
      "ipv6": {
        "ip": "2a01:4f8:c012:e2fa::/64",
        "blocked": false,
        "dns_ptr": [],
        "id": 7834447
      },
      "floating_ips": [],
      "firewalls": []
    },
    "private_net": [],
    "server_type": {
      "id": 1,
      "name": "cx11",
      "description": "CX11",
      "cores": 1,
      "memory": 2.0,
      "disk": 20,
      "deprecated": null,
      "prices": [
        {
          "location": "hel1",
          "price_hourly": {
            "net": "0.0055000000",
            "gross": "0.0055000000000000"
          },
          "price_monthly": {
            "net": "3.4900000000",
            "gross": "3.4900000000000000"
          }
        },
        {
          "location": "nbg1",
          "price_hourly": {
            "net": "0.0055000000",
            "gross": "0.0055000000000000"
          },
          "price_monthly": {
            "net": "3.4900000000",
            "gross": "3.4900000000000000"
          }
        },
        {
          "location": "fsn1",
          "price_hourly": {
            "net": "0.0055000000",
            "gross": "0.0055000000000000"
          },
          "price_monthly": {
            "net": "3.4900000000",
            "gross": "3.4900000000000000"
          }
        }
      ],
      "storage_type": "local",
      "cpu_type": "shared"
    },
    "datacenter": {
      "id": 4,
      "name": "fsn1-dc14",
      "description": "Falkenstein 1 DC14",
      "location": {
        "id": 1,
        "name": "fsn1",
        "description": "Falkenstein DC Park 1",
        "country": "DE",
        "city": "Falkenstein",
        "latitude": 50.47612,
        "longitude": 12.370071,
        "network_zone": "eu-central"
      },
      "server_types": {
        "supported": [
          1,
          3,
          5,
          7,
          9,
          11,
          12,
          13,
          14,
          15,
          22,
          23,
          24,
          25,
          26,
          33,
          34,
          35,
          36,
          37,
          38
        ],
        "available": [
          1,
          3,
          5,
          7,
          9,
          11,
          12,
          13,
          14,
          15,
          22,
          23,
          24,
          25,
          26,
          33,
          34,
          35,
          36,
          37,
          38
        ],
        "available_for_migration": [
          1,
          3,
          5,
          7,
          9,
          11,
          12,
          13,
          14,
          15,
          22,
          23,
          24,
          25,
          26,
          27,
          28,
          29,
          30,
          31,
          32,
          33,
          34,
          35,
          36,
          37,
          38
        ]
      }
    },
    "image": {
      "id": 168855,
      "type": "system",
      "status": "available",
      "name": "ubuntu-18.04",
      "description": "Ubuntu 18.04",
      "image_size": null,
      "disk_size": 5,
      "created": "2018-05-02T11:02:30+00:00",
      "created_from": null,
      "bound_to": null,
      "os_flavor": "ubuntu",
      "os_version": "18.04",
      "rapid_deploy": true,
      "protection": {
        "delete": false
      },
      "deprecated": null,
      "labels": {},
      "deleted": null
    },
    "iso": null,
    "rescue_enabled": false,
    "locked": false,
    "backup_window": null,
    "outgoing_traffic": null,
    "ingoing_traffic": null,
    "included_traffic": 21990232555520,
    "protection": {
      "delete": false,
      "rebuild": false
    },
    "labels": {},
    "volumes": [],
    "load_balancers": [],
    "primary_disk_size": 20,
    "placement_group": {
      "id": 46619,
      "name": "Orders",
      "labels": {},
      "type": "spread",
      "created": "2022-06-02T01:44:12.140093+00:00",
      "servers": [
        21018870
      ]
    }
  },
  "action": {
    "id": 499848708,
    "command": "create_server",
    "status": "running",
    "progress": 0,
    "started": "2022-06-03T21:57:06+00:00",
    "finished": null,
    "resources": [
      {
        "id": 21018870,
        "type": "server"
      }
    ],
    "error": null
  },
  "next_actions": [
    {
      "id": 499848706,
      "command": "start_server",
      "status": "running",
      "progress": 0,
      "started": "2022-06-03T21:57:06+00:00",
      "finished": null,
      "resources": [
        {
          "id": 21018870,
          "type": "server"
        }
      ],
      "error": null
    },
    {
      "id": 499848707,
      "command": "attach_volume",
      "status": "running",
      "progress": 0,
      "started": "2022-06-03T21:57:06+00:00",
      "finished": null,
      "resources": [
        {
          "id": 21018870,
          "type": "server"
        },
        {
          "id": 20041347,
          "type": "volume"
        }
      ],
      "error": null
    }
  ],
  "root_password": "jvuLsuRVxebt4fMengaA"
}
  • Вопрос задан
  • 76 просмотров
Решения вопроса 1
scottparker
@scottparker
это json-строка, декадируй его с помощью json_decode со вторым параметром true и обратись к элементу массива
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы