Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8706611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:39:21+00:00 2026-06-13T03:39:21+00:00

I am trying to parse json using json_decode in php. It is failing for

  • 0

I am trying to parse json using json_decode in php.
It is failing for a url, Can any one tell me why its failing and is there ant alternative to json_decode in php ?

Here is my code

$url='https://espn.go.com/travel/sports/calendar/getList.json?&xhr=1&date=20121027&type=list&query=null&myTeams=';
$html = file_get_html($url);     
$json=json_decode($html,true);

//json is null here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T03:39:22+00:00Added an answer on June 13, 2026 at 3:39 am

    file_get_html is PHP Simple HTML DOM Parser Not default PHP function It should be

     $html = file_get_contents($url);     
    

    Please also Note that the returned JSON has an error of Malformed UTF-8 characters, possibly incorrectly encoded

    To Fix THis

    $url = 'http://espn.go.com/travel/sports/calendar/getList.json?&xhr=1&date=20121027&type=list&query=null&myTeams=';
    $html = file_get_contents($url);
    $json = preg_replace('/,\s*([\]}])/m', '$1', utf8_encode($html));
    $json = json_decode($json);
    echo "<pre>";
    print_r($json);
    

    Output

    tdClass Object
    (
        [nfb] => Array
            (
                [0] => stdClass Object
                    (
                        [events] => Array
                            (
                                [0] => stdClass Object
                                    (
                                        [id] => 265911
                                        [time] => 12:00 AM ET
                                        [sportId] => 23
                                        [link] => http://espn.go.com/ncf/team/_/name/
                                        [prevLink] => http://espn.go.com/ncf/preview?gameId=323010002
                                        [recapLink] => http://espn.go.com/ncf/recap?gameId=323010002
                                        [shortSport] => ncaa
                                        [homeId] => 2
                                        [awayId] => 245
                                        [homeScore] => -1
    
            ... So Many More
    

    See Live Demo

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to retrieve articles through wikipedia API using this code $url = 'http://en.wikipedia.org/w/api.php?action=parse&page=example&format=json&prop=text';
I'm trying handle bad json data when parsed through json_decode(). I'm using the following
I am trying to parse a json object using gson in Android application ,the
I'm trying to parse some JSON coming from an AJAX request using jQuery. Basically,
First: this is my first time using GSON. Trying to parse some JSON, I
I am trying to convert some xml into a json object using PHP. This
I'm trying to upload and parse json files using django. Everything works great up
I'm trying to parse JSON Using ASIHttpRequset I wrote this code -(void) tryASIHttpRequest{ NSString
I'm trying to parse some json using Json.NET. The json either returns an array
Hi i am trying to parse Json using gson library.My Json String is this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.