mardi 29 septembre 2015

Laravel 5.1 Accessing Collection key / value

In Laravel 5.1 (PHP), I have a call as follows:

$CableSizes = CableType::getCableSizeList(1);

Which returns the following collection (as I understand). To show its contents I run dd($CableSizes);:

array:21 [▼
  0 => {#208 ▼
    +"cable_specification_id": 1
    +"cable_conductor_size_mm": "0.50"
  }
  1 => {#209 ▶}
  2 => {#210 ▶}
  3 => {#211 ▶}
  4 => {#212 ▶}
  5 => {#213 ▶}
  6 => {#214 ▶}
]

I can access the first element by doing dd($CableSizes[0]);. Ho do I access the contents on the first element, and retrieve cable_conductor_size or 0.50 in the example above). I am trying variations of dd($CableSizes[0].cable_conductor_size); but all returning errors.

I cannot seem to ask this question to Google so I get an example to view. How do I access this value?

Many thanks!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire