Дано:
<?php
$str = '{"1013":[{"type":6,"value":"The hormone hCG is released when you conceive, and may alter your mood."},{"type":8,"value":"Make sure you log your data to find a pattern between your symptoms, and whether or not you conceived."},{"type":7,"value":"You are approaching the end of your menstrual cycle and of the luteal phase. Progesterone will continue to be produced until the corpus luteum breaks down about 14 days after ovulation (it does not break down if an embryo implants). At this point, your uterine lining is of no use so your period will begin."}]}';
echo $str;
echo "<br><br>";
Используя $json = json_decode($string, true)
нужно вывести на экран данные касательно только {"type":8, "value"}
.
Как это правильно сделать? Пожалуйста подскажите! Особых идей нет, kак вариант:
<?php
$str = '{"1013":[{"type":6,"value":"The hormone hCG is released when you conceive, and may alter your mood."},{"type":8,"value":"Make sure you log your data to find a pattern between your symptoms, and whether or not you conceived."},{"type":7,"value":"You are approaching the end of your menstrual cycle and of the luteal phase. Progesterone will continue to be produced until the corpus luteum breaks down about 14 days after ovulation (it does not break down if an embryo implants). At this point, your uterine lining is of no use so your period will begin."}]}';
echo $str;
echo "<br><br>";
$element1 = array();
$element1["type"] = 6;
$element1["value"] = "The hormone hCG is released when you conceive, and may alter your mood.";
$element2 = array();
$element2["type"] = 8;
$element2["value"] = "Make sure you log your data to find a pattern between your symptoms, and whether or not you conceived.";
$element3 = array();
$element3["type"] = 7;
$element3["value"] = "You are approaching the end of your menstrual cycle and of the luteal phase. Progesterone will continue to be produced until the corpus luteum breaks down about 14 days after ovulation (it does not break down if an embryo implants). At this point, your uterine lining is of no use so your period will begin.";
$elements = array();
$elements[0] = $element1;
$elements[1] = $element2;
$elements[2] = $element3;
$final = array();
$final[1013] = $elements;
$json = json_decode($final, true);
echo $json;