How do you get the right part through the regular expression?
-
Use preg_match_all.
There's a page that needs to evaporate the code. The code itself looks like:
<script type="text/javascript" charset="utf-8"> var elements = {"a":1,"b":2,"c":3,"d":4,"e":5}; </script>
That's all I need to get is json-happiness.
{"a":1,"b":2,"c":3,"d":4,"e":5}
If used
if (preg_match_all('#var wallpapers = (.*?);#si',$image_page,$matchimages,PREG_SET_ORDER)) {
Got it.
var elements = {"a":1,"b":2,"c":3,"d":4,"e":5};
-
Check the contents.
$matchimages[0][1]
there should be a line.Or try something like this:
preg_match_all('/{[^}]*}/', $image_page, $matchimages);