Answer the question
In order to leave comments, you need to log in
How to find and convert data from a script tag, which is in json format, into a php array?
<script id="data" type="application/json">
[
{
"slide_1":"img/viewer/Winterfell.jpg",
},
{
"slide_1":"img/viewer/The_Eyrie.jpg",
},
{
"slide_1":"img/viewer/Riverrun.jpg",
},
{
"slide_1":"img/viewer/Pyke.jpg",
},
]
</script>
Answer the question
In order to leave comments, you need to log in
$html = '....';
preg_match('@<script(?:[^>]*\stype="(?:application|text)/json")?[^>]*>(.*?)</script>@s', $html, $data);
$data = json_decode($data[1]);
print_r($data);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question