0

I have a PHP application that connects to a firebase realtime database. I am able to connect successfully to pull the data, but decoding the record to obtain the values is giving me problems. Below is a sample data received when I query the database from firebase.

{
  "2bzVFsyl": {
    "QApH4d4kYRTn5YDqHpzlVQyVlt63": {
      "item_description": "iPhone 8",
      "item_name": "iPhone 8",
      "item_type": "Box",
      "item_weight": "1.25",
      "quantity": "1",
      "ride_id": "waiting",
      "weight_measurement": "lbs"
    }
  },
  "8cOX27Mf": {
    "QApH4d4kYRTn5YDqHpzlVQyVlt63": {
      "item_description": "Brand new iPhone 7 Plus sealed in Box.",
      "item_name": "iPhone 7 Plus",
      "item_type": "Box",
      "item_weight": "1.92",
      "quantity": "1",
      "ride_id": "waiting",
      "weight_measurement": "lbs"
    }
  },
  "EdQo1vKa": {
    "QApH4d4kYRTn5YDqHpzlVQyVlt63": {
      "item_description": "iPhone 7 Plus.",
      "item_name": "iPhone 7 Plus",
      "item_type": "Box",
      "item_weight": "0.078",
      "quantity": "2",
      "ride_id": "waiting",
      "weight_measurement": "kg"
    }
  },
  "fEapPh6B": {
    "QApH4d4kYRTn5YDqHpzlVQyVlt63": {
      "item_description": "Brand new in the box",
      "item_name": "Macbook Pro",
      "item_type": "Box",
      "item_weight": "0.8",
      "quantity": "2",
      "ride_id": "-NMEGOW7uOqMgP6Vg6O1",
      "weight_measurement": "kg"
    }
  },
  "yUZ8DAW5": {
    "QApH4d4kYRTn5YDqHpzlVQyVlt63": {
      "item_description": "Five bags of rice.",
      "item_name": "Bags of rice",
      "item_type": "Box",
      "item_weight": "50",
      "quantity": "5",
      "ride_id": "waiting",
      "weight_measurement": "kg"
    }
  }
}

Kindly assist me to obtain the values in the data above.

Dharmaraj
  • 47,845
  • 8
  • 52
  • 84
N. Felix
  • 69
  • 1
  • 10
  • no please. I get 'Warning: Attempt to read property "item_name" on array in C:\Xampp_folder\htdocs\new\linkup_admin\dashboard.php on line 8' feedback – N. Felix Mar 15 '23 at 09:56
  • 1
    Sounds like it did help, but you're using the result wrong. If it's an array, use it as an array and not as an object. We can't really be more specific since we have no idea what you're actually doing. – M. Eriksson Mar 15 '23 at 11:03
  • "Questions seeking debugging help ('**why isn't this code working?**') must include the desired behavior, a *specific problem or error* and *the shortest code necessary* to reproduce it **in the question itself**. Questions without **a clear problem statement** are not useful to other readers. See: [How to create a Minimal, Complete, and Verifiable example.](http://stackoverflow.com/help/mcve)" – Frank van Puffelen Mar 15 '23 at 13:41

0 Answers0