I am using an api for film dates and im trying to parse a json array. Ive tried to parse the release dates but i receive this error - Fatal error: Cannot use string offset as an array
Below is an example from the array
Array
(
[total] => 17
[movies] => Array
(
[0] => Array
(
[id] => 22494
[title] => Titanic (in 3D)
[year] => 1997
[mpaa_rating] => PG-13
[runtime] => 195
[critics_consensus] => A mostly unqualified triumph for Cameron, who offers a dizzying blend of spectacular visuals and old-fashioned melodrama.
[release_dates] => Array
(
[theater] => 2012-04-04
[dvd] => 1999-08-31
)
Here's my simple code that is receiving the error.
<?php
$url = 'http://api.rottentomatoes.com/api/public/v1.0/lists/movies/upcoming.json?apikey=px8rr7zr5c6qjwpea66gdf93&page_limit=18';
$json = file_get_contents($url);
$data = json_decode($json, TRUE);
foreach($json['releasedates']['theatre'] as $item) {
print $item['theatre'];
}
?>
Ideally i want to parse the dates into a variable and be able to compare them to the current day
Thanks for your help guys :)