Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jhutto's avatar

Array Key not accessable - Array in Array from API

I have a project where I'm getting data from an Application API.... The data is pulling but I can't access it because the keys are from the application. How do I access the array within this array?

array:5 [▼
  "courses" => array:3 [▼
    "6090c0bccb0fae02bb1119d6" => array:44 [▶]
			"title" => "Test#1"
			"titleId" => "1"
			"id" => "6090c0bccb0fae02bb1119d6"
    "6111d4ef584eea77e516af9f" => array:44 [▶]
    "6112bce443f65c4dab0092e4" => array:44 [▶]
  ]
  "errors" => []
  "success" => true
]

0 likes
2 replies
jlrdw's avatar

Put it into a variable.

Then, just example you would have things like:

$data["courses"][0]  

Just an example and suggestion.

automica's avatar
automica
Best Answer
Level 54

@jlrdw $data["courses"][0] won't work as you have UUID keys.

however if you do the following:

$courses = array_values($data['courses']);

This will reindex and get rid of UUID keys and you'd then be able to access the data as $courses[0] etc

Please or to participate in this conversation.