Why can't I close json data? _ (: invalid "response) _ http: // 202.103.244.125/catst. php
As mentioned above, PHP is so anxious! Json_decode always comes out of null !!! I have tried all the methods on the internet. please help me.
Reply to discussion (solution)
I don't believe you have tried it.
$url = 'http://202.103.244.125/catst.php';$s = file_get_contents($url);print_r(json_decode(substr($s, 3)));
Array ([0] => stdClass Object ([menutype] => A [groupx] => 0 [titleng] => Dish [titlech] => Cold Dish) [1] => stdClass Object ([menutype] => A [groupx] => 1 [titleng] => Soup Porrdg) [2] => stdClass Object ([menutype] => A [groupx] => 2 [titleng] => Hot food [titlech] => Hot food) [3] => stdClass Object ([menutype] => A [groupx] => 3 [titleng] => vegetarian dishes [titlech] => Veget-able) [4] => stdClass Object ([menutype] => A [groupx] => 4 [titleng] => staple Food [titlech] => Main Food) [5] => stdClass Object ([menutype] => A [groupx] => 5 [titleng] => grilled fish beer fish [titlech] => grilled fish beer fish) [6] => stdClass Object ([menutype] => A [groupx] => 6 [titleng] => dry pot [titlech] => Gangou Hotpot) [7] => stdClass Object ([menutype] => A [groupx] => 7 [titleng] => titlech [titlech] => Sheet Hotpot) [8] => stdClass Object ([menutype] => A [groupx] => 8 [titleng] => casserole [titlech] => Sha Guo) [9] => stdClass Object ([menutype] => A [groupx] => 9 [titleng] => [titlech] =>) [10] => stdClass Object ([menutype] => A [groupx] => 10 [titleng] => [titlech] => Special Food) [11] => stdClass Object ([menutype] => A [groupx] => 11 [titleng] => 18 brewed [titlech] => 18 brewed) [12] => stdClass Object ([menutype] => A [groupx] => 12 [titleng] => beverage Tea [titlech] => Drink Tea) [13] => stdClass Object ([menutype] => A [groupx] => 13 [titleng] => other custom [titlech] => other custom) [14] => stdClass Object ([menutype] => A [groupx] => 14 [titleng] => liquor Beer [titlech] => Wine Beer ))
Get a BOM header to harm yourself
Http: // 202.103.244.125/catst. php
As mentioned above, PHP is so anxious! Json_decode always comes out of null !!! I have tried all the methods on the internet. please help me.
Positive solution
I don't believe you have tried it.
$url = 'http://202.103.244.125/catst.php';$s = file_get_contents($url);print_r(json_decode(substr($s, 3)));
Array ([0] => stdClass Object ([menutype] => A [groupx] => 0 [titleng] => Dish [titlech] => Cold Dish) [1] => stdClass Object ([menutype] => A [groupx] => 1 [titleng] => Soup Porrdg) [2] => stdClass Object ([menutype] => A [groupx] => 2 [titleng] => Hot food [titlech] => Hot food) [3] => stdClass Object ([menutype] => A [groupx] => 3 [titleng] => vegetarian dishes [titlech] => Veget-able) [4] => stdClass Object ([menutype] => A [groupx] => 4 [titleng] => staple Food [titlech] => Main Food) [5] => stdClass Object ([menutype] => A [groupx] => 5 [titleng] => grilled fish beer fish [titlech] => grilled fish beer fish) [6] => stdClass Object ([menutype] => A [groupx] => 6 [titleng] => dry pot [titlech] => Gangou Hotpot) [7] => stdClass Object ([menutype] => A [groupx] => 7 [titleng] => titlech [titlech] => Sheet Hotpot) [8] => stdClass Object ([menutype] => A [groupx] => 8 [titleng] => casserole [titlech] => Sha Guo) [9] => stdClass Object ([menutype] => A [groupx] => 9 [titleng] => [titlech] =>) [10] => stdClass Object ([menutype] => A [groupx] => 10 [titleng] => [titlech] => Special Food) [11] => stdClass Object ([menutype] => A [groupx] => 11 [titleng] => 18 brewed [titlech] => 18 brewed) [12] => stdClass Object ([menutype] => A [groupx] => 12 [titleng] => beverage Tea [titlech] => Drink Tea) [13] => stdClass Object ([menutype] => A [groupx] => 13 [titleng] => other custom [titlech] => other custom) [14] => stdClass Object ([menutype] => A [groupx] => 14 [titleng] => liquor Beer [titlech] => Wine Beer ))
It seems like you have done it !!!
Why is the substr () parameter 3? Is it 3 if other json files are processed? Do you still need to make a decision?
The BOM header of UTF-8 is three characters. Therefore, use substr to skip the first three characters.
Since json is output, the program file must be savedUTF-8 without BOMFormat
Thank you !!