Hallo zusammen,
ich habe folgendes Array
"{"userRole":1,"vat":0.0,"partnerId":20,"useDynami cMaster":false,"circuits":[{"chargers":[{"userRole":null,"isTemporary":false,"id":"EH11111 ","name":"Easee Home 11111","color":5,"createdOn":"2020-02-06T13:13:00.844131","updatedOn":"2020-08-11T19:31:56.992034","backPlate":{"id":"111111","ma sterBackPlateId":"111111","name":" Easee Home 11111"},"levelOfAccess":null,"productCode":null}],"masterBackplate":null,"useDynamicMaster":fals e," parentCircuitId":null,"id":72111,"siteId":74111,"circuitPanelId":9,"panelName":"9" ,"ratedCurrent":16 .0}],"equalizers":[],"createdOn":"2021-03-11T13:36:36.24942","updatedOn":"2021-04-03T05:43:25.990776","contactInfo":{"installerName" :null,"installerPhoneNumber":null,"ownerName":"Nam e","ownerPhoneNumber":"Tel","company" :null},"costPerKWh":0.0,"costPerKwhExcludeVat":0.0 ,"currencyId":"NOK","siteType":1,"ratedCurrent" :63 .0,"id":74111,"siteKey":"1111-1111","name":"Stadt","levelOfAccess":1,"address":{ "street":"","buildingNumber":"","zip":"","area":"" ,"country":null," latitude":null,"longitude":null,"altitude":null}}"[LF]
bzw nach einem json_decode so
maxCircuitCurrent - DATA:array(19) {[LF] ["userRole"]=>[LF] int(1)[LF] ["vat"]=>[LF] float(0)[LF] ["partnerId"]=>[LF] int(20)[LF] ["useDynamicMaster"]=>[LF] bool(false)[LF] ["circuits"]=>[LF] array(1) {[LF] [0]=>[LF] array(9) {[LF] ["chargers"]=>[LF] array(1) {[LF] [0]=>[LF] array(10) {[LF] ["userRole"]=>[LF] NULL[LF] ["isTemporary"]=>[LF] bool(false)[LF] ["id"]=>[LF] string(8) "EH11111"[LF] ["name"]=>[LF] string(16) "Easee Home 11111"[LF] ["color"]=>[LF] int(5)[LF] ["createdOn"]=>[LF] string(26) "2021-02-08T13:13:00.844131"[LF] ["updatedOn"]=>[LF] string(26) "2021-09-11T19:31:56.992034"[LF] ["backPlate"]=>[LF] array(3) {[LF] ["id"]=>[LF] string(14) "11111"[LF] ["masterBackPlateId"]=>[LF] string(14) "11111"[LF] ["name"]=>[LF] string(16) "Easee Home 11111"[LF] }[LF] ["levelOfAccess"]=>[LF] NULL[LF] ["productCode"]=>[LF] NULL[LF] }[LF] }[LF] ["masterBackplate"]=>[LF] NULL[LF] ["useDynamicMaster"]=>[LF] bool(false)[LF] ["parentCircuitId"]=>[LF] NULL[LF] ["id"]=>[LF] int(72111)[LF] ["siteId"]=>[LF] int(74111)[LF] ["circuitPanelId"]=>[LF] int(9)[LF] ["panelName"]=>[LF] string(1) "9"[LF] ["ratedCurrent"]=>[LF] float(16)[LF] }[LF] }[LF] ["equalizers"]=>[LF] array(0) {[LF] }[LF] ["createdOn"]=>[LF] string(25) "2021-03-11T13:36:36.24942"[LF] ["updatedOn"]=>[LF] string(26) "2021-04-03T05:43:25.990776"[LF] ["contactInfo"]=>[LF] array(5) {[LF] ["installerName"]=>[LF] NULL[LF] ["installerPhoneNumber"]=>[LF] NULL[LF] ["ownerName"]=>[LF] string(10) "Name"[LF] ["ownerPhoneNumber"]=>[LF] string(13) "+49111111111"[LF] ["company"]=>[LF] NULL[LF] }[LF] ["costPerKWh"]=>[LF] float(0)[LF] ["costPerKwhExcludeVat"]=>[LF] float(0)[LF] ["currencyId"]=>[LF] string(3) "NOK"[LF] ["siteType"]=>[LF] int(1)[LF] ["ratedCurrent"]=>[LF] float(63)[LF] ["id"]=>[LF] int(74111)[LF] ["siteKey"]=>[LF] string(9) "1111-L111"[LF] ["name"]=>[LF] string(27) "Stadt"[LF] ["levelOfAccess"]=>[LF] int(1)[LF] ["address"]=>[LF] array(8) {[LF] ["street"]=>[LF] string(0) ""[LF] ["buildingNumber"]=>[LF] string(0) ""[LF] ["zip"]=>[LF] string(0) ""[LF] ["area"]=>[LF] string(0) ""[LF] ["country"]=>[LF] NULL[LF] ["latitude"]=>[LF] NULL[LF] ["longitude"]=>[LF] NULL[LF] ["altitude"]=>[LF] NULL[LF] }[LF]}[LF]
Ich möchte den Wert (gelb) in einer Variable haben.
Aber alles was ich versucht habe geht nicht ...
$circuitsID = $data['circuits']['id'];
oder mit
array_search
Bei anderen Array funktioniert diese Methode (circuitsID = $data['circuits']['id']
nur bei diesem komme ich irgendwie nicht weiter
*habe die Daten im Array etwas verfälscht, da zu persönlich. Struktur ist aber gleich
ich habe folgendes Array
"{"userRole":1,"vat":0.0,"partnerId":20,"useDynami cMaster":false,"circuits":[{"chargers":[{"userRole":null,"isTemporary":false,"id":"EH11111 ","name":"Easee Home 11111","color":5,"createdOn":"2020-02-06T13:13:00.844131","updatedOn":"2020-08-11T19:31:56.992034","backPlate":{"id":"111111","ma sterBackPlateId":"111111","name":" Easee Home 11111"},"levelOfAccess":null,"productCode":null}],"masterBackplate":null,"useDynamicMaster":fals e," parentCircuitId":null,"id":72111,"siteId":74111,"circuitPanelId":9,"panelName":"9" ,"ratedCurrent":16 .0}],"equalizers":[],"createdOn":"2021-03-11T13:36:36.24942","updatedOn":"2021-04-03T05:43:25.990776","contactInfo":{"installerName" :null,"installerPhoneNumber":null,"ownerName":"Nam e","ownerPhoneNumber":"Tel","company" :null},"costPerKWh":0.0,"costPerKwhExcludeVat":0.0 ,"currencyId":"NOK","siteType":1,"ratedCurrent" :63 .0,"id":74111,"siteKey":"1111-1111","name":"Stadt","levelOfAccess":1,"address":{ "street":"","buildingNumber":"","zip":"","area":"" ,"country":null," latitude":null,"longitude":null,"altitude":null}}"[LF]
bzw nach einem json_decode so
maxCircuitCurrent - DATA:array(19) {[LF] ["userRole"]=>[LF] int(1)[LF] ["vat"]=>[LF] float(0)[LF] ["partnerId"]=>[LF] int(20)[LF] ["useDynamicMaster"]=>[LF] bool(false)[LF] ["circuits"]=>[LF] array(1) {[LF] [0]=>[LF] array(9) {[LF] ["chargers"]=>[LF] array(1) {[LF] [0]=>[LF] array(10) {[LF] ["userRole"]=>[LF] NULL[LF] ["isTemporary"]=>[LF] bool(false)[LF] ["id"]=>[LF] string(8) "EH11111"[LF] ["name"]=>[LF] string(16) "Easee Home 11111"[LF] ["color"]=>[LF] int(5)[LF] ["createdOn"]=>[LF] string(26) "2021-02-08T13:13:00.844131"[LF] ["updatedOn"]=>[LF] string(26) "2021-09-11T19:31:56.992034"[LF] ["backPlate"]=>[LF] array(3) {[LF] ["id"]=>[LF] string(14) "11111"[LF] ["masterBackPlateId"]=>[LF] string(14) "11111"[LF] ["name"]=>[LF] string(16) "Easee Home 11111"[LF] }[LF] ["levelOfAccess"]=>[LF] NULL[LF] ["productCode"]=>[LF] NULL[LF] }[LF] }[LF] ["masterBackplate"]=>[LF] NULL[LF] ["useDynamicMaster"]=>[LF] bool(false)[LF] ["parentCircuitId"]=>[LF] NULL[LF] ["id"]=>[LF] int(72111)[LF] ["siteId"]=>[LF] int(74111)[LF] ["circuitPanelId"]=>[LF] int(9)[LF] ["panelName"]=>[LF] string(1) "9"[LF] ["ratedCurrent"]=>[LF] float(16)[LF] }[LF] }[LF] ["equalizers"]=>[LF] array(0) {[LF] }[LF] ["createdOn"]=>[LF] string(25) "2021-03-11T13:36:36.24942"[LF] ["updatedOn"]=>[LF] string(26) "2021-04-03T05:43:25.990776"[LF] ["contactInfo"]=>[LF] array(5) {[LF] ["installerName"]=>[LF] NULL[LF] ["installerPhoneNumber"]=>[LF] NULL[LF] ["ownerName"]=>[LF] string(10) "Name"[LF] ["ownerPhoneNumber"]=>[LF] string(13) "+49111111111"[LF] ["company"]=>[LF] NULL[LF] }[LF] ["costPerKWh"]=>[LF] float(0)[LF] ["costPerKwhExcludeVat"]=>[LF] float(0)[LF] ["currencyId"]=>[LF] string(3) "NOK"[LF] ["siteType"]=>[LF] int(1)[LF] ["ratedCurrent"]=>[LF] float(63)[LF] ["id"]=>[LF] int(74111)[LF] ["siteKey"]=>[LF] string(9) "1111-L111"[LF] ["name"]=>[LF] string(27) "Stadt"[LF] ["levelOfAccess"]=>[LF] int(1)[LF] ["address"]=>[LF] array(8) {[LF] ["street"]=>[LF] string(0) ""[LF] ["buildingNumber"]=>[LF] string(0) ""[LF] ["zip"]=>[LF] string(0) ""[LF] ["area"]=>[LF] string(0) ""[LF] ["country"]=>[LF] NULL[LF] ["latitude"]=>[LF] NULL[LF] ["longitude"]=>[LF] NULL[LF] ["altitude"]=>[LF] NULL[LF] }[LF]}[LF]
Ich möchte den Wert (gelb) in einer Variable haben.
Aber alles was ich versucht habe geht nicht ...
$circuitsID = $data['circuits']['id'];
oder mit
array_search
Bei anderen Array funktioniert diese Methode (circuitsID = $data['circuits']['id']

*habe die Daten im Array etwas verfälscht, da zu persönlich. Struktur ist aber gleich
Kommentar