Skip to content
Advertisement

PHP read JSON Array with unknown variable

I have a Json Script with an Array inside and Array which looks like this shortened:

JavaScript

Now I want to work with the single variables shortName, industry, etc. When I tried to call the function with

JavaScript

it worked perfectly fine. When I use

JavaScript

it is not working at all and gives me the following warning:

Warning: Undefined array key “assets” in C:xampphtdocstestergebnisdarstellung.php on line 52

Warning: Trying to access array offset on value of type null in C:xampphtdocstestergebnisdarstellung.php on line 52

The problem I have is that I will not know what name will be in the second brackets like CGGD.AS and because of this I can not use the working function. I will not now how long the array is either and numbers are not working. Because of this I do not know how to call the single variabless without using the name. How can I call the function?

Advertisement

Answer

To get all shortName you can loop your array:

JavaScript

If you want just shortName of first element, then use current:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement