P
P
PanCar2021-07-15 16:53:41
PHP
PanCar, 2021-07-15 16:53:41

I have an array in which there is a key and text in it, and I need to display data from this key. How to do it?

Good day. I have a question: I have an array in which there is 1 key and text in it, and I need to display data from this key. For example, I need to display each place, how to do it correctly?
The whole array looks like this:


  • Array
    (
    [0] => { "status": "OK", "className": "M14", "splitcontrols": [], "results": [{"place": "1", "name": "Niklāvs Dravants ", "club": "Meridiāns-CPSS-Pārgauja", "result": "121700", "status" : 0, "timeplus": "0", "progress": 100 , "start": 4230000},{ "place": "2", "name": "Krīvs Edgars Rožukalns", "club": "Auseklis IK", "result": "133900", "status" : 0, "timeplus": "12200", " progress": 100 , "start": 4245400},{"place": "3", "name": "Ralfs Prauliņš", "club": "Alnis OK-JNSC","result": "147000", "status" : 0, "timeplus": "25300", "progress": 100 , "start": 4319400},{"place": "4", "name": "Olivers Plociņš", "club": "Ogre OK/SC", "result": "152700", "status" : 0, "timeplus": "31000", "progress": 100 , "start": 4251500},{ "place": "5", "name": "Bruno Šterns", "club": "Ogre OK/SC", "result": "154800", "status" : 0, "timeplus": "33100", "progress": 100 , "start": 4249000},{"place": "6", "name": "Mārtiņš Cīrulis", "club": "Auseklis IK", "result": "167400", "status" : 0, "timeplus": "45700", "progress": 100 , "start": 4422000},{"place": "7", "name": "Otto Otomārs Veips", "club": "Ogre OK/SC", "result": "180600", "status" : 0, "timeplus": "58900", "progress": 100 , "start": 4316600},{ "place": "8", "name": "Rihards Žilinskis", "club": "Eko O", "result": "187700", "status" : 0, "timeplus": "66000", "progress ": 100 , "start": 4419000},{"place": "9", "name": "Dāvis Strīķis", "club": "Alnis OK-JNSC", "result": "194500", "status" : 0, "timeplus": "72800", "progress": 100 , "start": 4416000},{"place": "10", "name": "Raitis Kārkliņš ", "club": "Alnis OK-JNSC", "result": "196200", "status" : 0, "timeplus": "74500", "progress": 100 , "start": 4413000},{" place": "11", "name": "Gregors Grāls", "club": "Preetzer TSV", "result": "206000", "status" : 0, "timeplus": "84300", "progress" : 100 , "start": 4410000},{"place": "12", "name": "Gustavs Blumbergs", "club": "Ikšķiles SS","result": "454400", "status" : 0, "timeplus": "332700", "progress": 100 , "start": 4425000},{"place": "", "name": " Vacant" , "club": "Vacant", "result": "", "status" : 9, "timeplus": "", "progress": 0 , "start": 4428000}], "hash": "734721b986a649b818004035ccb90d26" }progress": 0 , "start": 4428000}], "hash": "734721b986a649b818004035ccb90d26"}progress": 0 , "start": 4428000}], "hash": "734721b986a649b818004035ccb90d26"}
    )

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
galaxy, 2021-07-15
@PanCar

foreach (json_decode($array[0])->results as $r) print $r->place . "\n";

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question