bokovua
@bokovua
Любитель

Выбрать из json и сопоставить с переменной php, затем вывести?

Здравствуйте! Есть JSON. Это данные погоды. В коде представлены данные на несколько дней.
На странице с контентом есть дни недели, которые равны переменным в php.
Вопрос: как из потока данных в json (уже деконирован в php) выбрать данные так, чтобы произошла буквальная выборка. Например:
Понедельник = $mon и т.д.
Далее нужно найти в json значение с фактической датой и днем недели равной "Понедельник" и если совпадение c переменной $mon по дню недели произошло, то - вывести его на странице с полными данными (температура и тд).

Другими словами, если в данных json были обнаружены данные с датой, которая обозначена изначально на странице, то "подхватить их" и вывести в соответствующей ячейке.

{"cod":"200","message":0.01,"cnt":40,"list":[{"dt":1547845200,"main":{"temp":2.4,"temp_min":2.4,"temp_max":2.4,"pressure":1004.72,"sea_level":1029.91,"grnd_level":1004.72,"humidity":97,"temp_kf":0},"weather":[{"id":500,"main":"Rain","description":"легкий дождь","icon":"10n"}],"clouds":{"all":80},"wind":{"speed":4.41,"deg":221.503},"rain":{"3h":0.2075},"snow":{},"sys":{"pod":"n"},"dt_txt":"2019-01-18 21:00:00"},{"dt":1547856000,"main":{"temp":2.04,"temp_min":2.04,"temp_max":2.04,"pressure":1004.58,"sea_level":1029.67,"grnd_level":1004.58,"humidity":97,"temp_kf":0},"weather":[{"id":500,"main":"Rain","description":"легкий дождь","icon":"10n"}],"clouds":{"all":92},"wind":{"speed":4.32,"deg":217.5},"rain":{"3h":0.12},"snow":{},"sys":{"pod":"n"},"dt_txt":"2019-01-19 00:00:00"},{"dt":1547866800,"main":{"temp":1.79,"temp_min":1.79,"temp_max":1.79,"pressure":1004.11,"sea_level":1029.16,"grnd_level":1004.11,"humidity":97,"temp_kf":0},"weather":[{"id":500,"main":"Rain","description":"легкий дождь","icon":"10n"}],"clouds":{"all":92},"wind":{"speed":4.11,"deg":219.504},"rain":{"3h":0.12},"snow":{},"sys":{"pod":"n"},"dt_txt":"2019-01-19 03:00:00"},{"dt":1547877600,"main":{"temp":1.57,"temp_min":1.57,"temp_max":1.57,"pressure":1003.84,"sea_level":1029.08,"grnd_level":1003.84,"humidity":98,"temp_kf":0},"weather":[{"id":500,"main":"Rain","description":"легкий дождь","icon":"10d"}],"clouds":{"all":92},"wind":{"speed":4.06,"deg":223.501},"rain":{"3h":0.105},"snow":{},"sys":{"pod":"d"},"dt_txt":"2019-01-19 06:00:00"},{"dt":1547888400,"main":{"temp":1.7,"temp_min":1.7,"temp_max":1.7,"pressure":1004.19,"sea_level":1029.41,"grnd_level":1004.19,"humidity":97,"temp_kf":0},"weather":[{"id":500,"main":"Rain","description":"легкий дождь","icon":"10d"}],"clouds":{"all":92},"wind":{"speed":3.66,"deg":243.003},"rain":{"3h":0.165},"snow":{},"sys":{"pod":"d"},"dt_txt":"2019-01-19 09:00:00"},{"dt":1547899200,"main":{"temp":1.08,"temp_min":1.08,"temp_max":1.08,"pressure":1005.34,"sea_level":1030.54,"grnd_level":1005.34,"humidity":97,"temp_kf":0},"weather":[{"id":500,"main":"Rain","description":"легкий дождь","icon":"10d"}],"clouds":{"all":64},"wind":{"speed":3.4,"deg":307.501},"rain":{"3h":0.075},"snow":{"3h":0.008},"sys":{"pod":"d"},"dt_txt":"2019-01-19 12:00:00"},{"dt":1547910000,"main":{"temp":-0.16,"temp_min":-0.16,"temp_max":-0.16,"pressure":1007.77,"sea_level":1033.29,"grnd_level":1007.77,"humidity":99,"temp_kf":0},"weather":[{"id":600,"main":"Snow","description":"небольшой снегопад","icon":"13n"}],"clouds":{"all":36},"wind":{"speed":4.31,"deg":334},"rain":{},"snow":{"3h":0.04875},"sys":{"pod":"n"},"dt_txt":"2019-01-19 15:00:00"},{"dt":1547920800,"main":{"temp":-3.54,"temp_min":-3.54,"temp_max":-3.54,"pressure":1010.07,"sea_level":1035.79,"grnd_level":1010.07,"humidity":93,"temp_kf":0},"weather":[{"id":500,"main":"Rain","description":"легкий дождь","icon":"10n"}],"clouds":{"all":0},"wind":{"speed":4.66,"deg":348},"rain":{"3h":0.005},"snow":{"3h":0.0325},"sys":{"pod":"n"},"dt_txt":"2019-01-19 18:00:00"},{"dt":1547931600,"main":{"temp":-8.38,"temp_min":-8.38,"temp_max":-8.38,"pressure":1011.89,"sea_level":1038.07,"grnd_level":1011.89,"humidity":85,"temp_kf":0},"weather":[{"id":800,"main":"Clear","description":"ясно","icon":"01n"}],"clouds":{"all":0},"wind":{"speed":3.91,"deg":355.004},"rain":{},"snow":{},"sys":{"pod":"n"},"dt_txt":"2019-01-19 21:00:00"},{"dt":1547942400,"main":{"temp":-12.28,"temp_min":-12.28,"temp_max":-12.28,"pressure":1012.84,"sea_level":1039.34,"grnd_level":1012.84,"humidity":82,"temp_kf":0},"weather":[{"id":800,"main":"Clear","description":"ясно","icon":"01n"}],"clouds":{"all":0},"wind":{"speed":1.77,"deg":335.501},"rain":{},"snow":{},"sys":{"pod":"n"},"dt_txt":"2019-01-20 00:00:00"},{"dt":1547953200,"main":{"temp":-12.82,"temp_min":-12.82,"temp_max":-12.82,"pressure":1013.61,"sea_level":1040.25,"grnd_level":1013.61,"humidity":71,"temp_kf":0},"weather":[{"id":800,"main":"Clear","description":"ясно","icon":"01n"}],"clouds":{"all":32},"wind":{"speed":3.06,"deg":352},"rain":{},"snow":{"3h":0.01625},"sys":{"pod":"n"},"dt_txt":"2019-01-20 03:00:00"},{"dt":1547964000,"main":{"temp":-12.79,"temp_min":-12.79,"temp_max":-12.79,"pressure":1014.61,"sea_level":1041.38,"grnd_level":1014.61,"humidity":78,"temp_kf":0},"weather":[{"id":600,"main":"Snow","description":"небольшой снегопад","icon":"13d"}],"clouds":{"all":32},"wind":{"speed":1.58,"deg":13.0028},"rain":{},"snow":{"3h":0.03},"sys":{"pod":"d"},"dt_txt":"2019-01-20 06:00:00"},{"dt":1547974800,"main":{"temp":-10.42,"temp_min":-10.42,"temp_max":-10.42,"pressure":1014.43,"sea_level":1040.91,"grnd_level":1014.43,"humidity":100,"temp_kf":0},"weather":[{"id":800,"main":"Clear","description":"ясно","icon":"01d"}],"clouds":{"all":20},"wind":{"speed":1.91,"deg":42},"rain":{},"snow":{"3h":0.0175},"sys":{"pod":"d"},"dt_txt":"2019-01-20 09:00:00"},{"dt":1547985600,"main":{"temp":-8.42,"temp_min":-8.42,"temp_max":-8.42,"pressure":1013.02,"sea_level":1039.29,"grnd_level":1013.02,"humidity":90,"temp_kf":0},"weather":[{"id":800,"main":"Clear","description":"ясно","icon":"01d"}],"clouds":{"all":24},"wind":{"speed":1.97,"deg":86.5023},"rain":{},"snow":{"3h":0.0025},"sys":{"pod":"d"},"dt_txt":"2019-01-20 12:00:00"},{"dt":1547996400,"main":{"temp":-12.92,"temp_min":-12.92,"temp_max":-12.92,"pressure":1012.19,"sea_level":1038.74,"grnd_level":1012.19,"humidity":79,"temp_kf":0},"weather":[{"id":800,"main":"Clear","description":"ясно","icon":"01n"}],"clouds":{"all":0},"wind":{"speed":1.53,"deg":80.0035},"rain":{},"snow":{},"sys":{"pod":"n"},"dt_txt":"2019-01-20 15:00:00"},{"dt":1548007200,"main":{"temp":-14.37,"temp_min":-14.37,"temp_max":-14.37,"pressure":1010.91,"sea_level":1037.46,"grnd_level":1010.91,"humidity":72,"temp_kf":0},"weather":[{"id":801,"main":"Clouds","description":"облачно","icon":"02n"}],"clouds":{"all":12},"wind":{"speed":3.07,"deg":107.5},"rain":{},"snow":{},"sys":{"pod":"n"},"dt_txt":"2019-01-20 18:00:00"},{"dt":1548018000,"main":{"temp":-10.38,"temp_min":-10.38,"temp_max":-10.38,"pressure":1009.06,"sea_level":1035.35,"grnd_level":1009.06,"humidity":87,"temp_kf":0},"weather":[{"id":600,"main":"Snow","description":"небольшой снегопад","icon":"13n"}],"clouds":{"all":76},"wind":{"speed":3.32,"deg":142.507},"rain":{},"snow":{"3h":0.06},"sys":{"pod":"n"},"dt_txt":"2019-01-20 21:00:00"},{"dt":1548028800,"main":{"temp":-7.9,"temp_min":-7.9,"temp_max":-7.9,"pressure":1007.15,"sea_level":1033.25,"grnd_level":1007.15,"humidity":91,"temp_kf":0},"weather":[{"id":600,"main":"Snow","description":"небольшой снегопад","icon":"13n"}],"clouds":{"all":88},"wind":{"speed":3.07,"deg":145.003},"rain":{},"snow":{"3h":0.1025},"sys":{"pod":"n"},"dt_txt":"2019-01-21 00:00:00"},{"dt":1548039600,"main":{"temp":-6.08,"temp_min":-6.08,"temp_max":- <b>и т.д.</b>
  • Вопрос задан
  • 70 просмотров
Пригласить эксперта
Ответы на вопрос 1
atomrus1993
@atomrus1993
Перебрать массив list сравнивая нужную дату и вытаскивать нужные данные
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы