不知道如何在PHP中链接json 100%

时间:2010-05-04 20:19:30

标签: php android json hyperlink

我试图创建一个我的机器人应用程序读取的RSS源但我有一些漏洞,我可以知道如何修复json链接页面是http://www.mandarich.com/mandarichServer/mlb/indexbaseball.php当读取json我可以看到图标丢失的位置一些人无法弄清楚原因。主要仅针对像纽约和芝加哥这样的城市(有两个名字的城市) 我对php的代码如下:

<?php

$teams["boston"] = "bostonredsox.gif";
$teams["nyyankees"] = "nyyankees.gif";
$teams["baltimore"] = "baltimoreorioles.gif";
$teams["tampa"] = "tampabayrays.gif";
$teams["toronto"] = "torontobluejays.gif";
$teams["atlanta"] = "atlantabraves.gif";
$teams["florida"] = "floridamarlins.gif";
$teams["nymets"] = "newyorkmets.gif";
$teams["philadelphia"] = "philadelphiaphillies.gif";
$teams["washington"] = "washingtonnationals.gif";
$teams["chicagosox"] = "chicagowhitesox.gif";
$teams["cleveland"] = "clevelandindians.gif";   
$teams["detroit"] = "detroittigers.gif";
$teams["kansas"] = "kansascityroyals.gif";
$teams["minnesota"] = "minnesotatwins.gif";
$teams["chicagocubs"] = "chicagocubs.gif";
$teams["cincinnati"] = "cinncinatireds.gif";
$teams["houston"] = "houstonastros.gif";
$teams["milwaukee"] = "milwaukeebrewers.gif";
$teams["pittsburgh"] = "pitsburghpirates.gif";
$teams["St.Louis"] = "stlouiscardinals.gif";
$teams["LaAngels"] = "losangelesangels.gif";
$teams["oakland"] = "oaklandathletics.gif";
$teams["seattle"] = "seattlemariners.gif";
$teams["texas"] = "texasrangers.gif";
$teams["arizona"] = "arizonadiamondbacks.gif";
$teams["colorado"] = "coloradorockies.gif";
$teams["ladodgers"] = "losangelesdodgers.gif";
$teams["sandiego"] = "sandiegopadres.gif";
$teams["sanfrancisco"] = "sanfranciscogiants.gif";


$abbr["arizona"] = "ARI";
$abbr["oakland"] = "OAK";
$abbr["baltimore"] = "BAL";
$abbr["tampa"] = "TAM";
$abbr["boston"] = "BOS";
$abbr["nyyankees"] = "NYY";
$abbr["texas"] = "TEX";
$abbr["toronto"] = "TOR";
$abbr["LaAngels"] = "LAA";
$abbr["atlanta"] = "ALT";
$abbr["colorado"] = "COL";
$abbr["philadelphia"] = "PHI";  
$abbr["florida"] = "FLA";
$abbr["milwaukee"] = "MIL";
$abbr["washington"] = "WAS";
$abbr["chicagosox"] = "CHW";
$abbr["cleveland"] = "CLE";
$abbr["detroit"] = "DET";
$abbr["seattle"] = "SEA";
$abbr["sanfrancisco"] = "SFO";
$abbr["St.Louis"] = "STL";
$abbr["chicagocubs"] = "CHC";
$abbr["houston"] = "HOU";
$abbr["nymets"] = "NYM";
$abbr["cincinnati"] = "CIN";
$abbr["sandiego"] = "SDG";
$abbr["ladodgers"] = "LAD";
$abbr["pittsburgh"] = "PIT";
$abbr["minnesota"] = "MIN";
$abbr["kansas"] = "KAN";
?>

1 个答案:

答案 0 :(得分:0)

ST。路易斯在st.louis $abbrstlouis $teams。这可能是造成这个问题的原因。

至于其中一些出现而有些出现,我敢打赌你的问题是你正在使用team1team2来查找图片。如果是这种情况,那么你就有了大写/小写的问题。让一切都小写。最重要的是,team*中有空格,这会导致问题。因此,请尝试la dodgers

而不是ladodgers

希望这有帮助。