I’m having difficulties parsing a string. This is the structure I have:
"Title":"Avatar","Year":"2009","Rated":"PG-13","Released":"18 Dec 2009","Runtime":"2 h 42 min"
What I want to do is putting every result in an own variable so that I get $title, $year, $runtime and so on in the end.
I know, there’re a lot of different PHP functions for that but after trying numerous of them and not getting the result I wanted, I just need some help.
Because after few modification to your string, you can make it JSON string, by adding trailing
{and}. And calljson_decodefunction on modificated string:It works, just look at this demo. You can use variables like:
But if you really need
$title(I don’t suggest to do this) you can useextractfunctionAnd you can access it like: