fork(3) download
  1. <?php
  2. $json = '{
  3. "@attributes":{
  4. "NMchs":"10"
  5. },
  6. "links":{
  7. "@attributes":{
  8. "fUrlBase":"http:\/\/synd.cricbuzz.com\/j2me\/1.0\/flags\/team_"
  9. }
  10. },
  11. "match":[
  12. {
  13. "@attributes":{
  14. "id":"3",
  15. "type":"T20",
  16. "srs":"Indian Premier League 2013",
  17. "mchDesc":"KOL vs CHN",
  18. "mnum":"26th Match",
  19. "vcity":"Kolkata",
  20. "vcountry":"India",
  21. "grnd":"Eden Gardens",
  22. "inngCnt":"1",
  23. "datapath":"http:\/\/synd.cricbuzz.com\/j2me\/1.0\/match\/2013\/2013_T20_LEAGUE\/KOL_CHN_APR20\/"
  24. },
  25. "state":{
  26. "@attributes":{
  27. "mchState":"inprogress",
  28. "status":"KOL elect to bat",
  29. "TW":"Kolkata",
  30. "decisn":"Batting",
  31. "addnStatus":"",
  32. "splStatus":""
  33. }
  34. },
  35. "Tm":[
  36. {
  37. "@attributes":{
  38. "id":"63",
  39. "Name":"Kolkata",
  40. "sName":"KOL",
  41. "flag":"0"
  42. }
  43. },
  44. {
  45. "@attributes":{
  46. "id":"58",
  47. "Name":"Chennai",
  48. "sName":"CHN",
  49. "flag":"0"
  50. }
  51. }
  52. ],
  53. "Tme":{
  54. "@attributes":{
  55. "Dt":"Apr 20 2013",
  56. "stTme":"10:30",
  57. "enddt":"Apr 20 2013"
  58. }
  59. },
  60. "mscr":{
  61. "inngsdetail":{
  62. "@attributes":{
  63. "noofovers":"50",
  64. "rrr":"0",
  65. "crr":"6.49",
  66. "cprtshp":"11(13)"
  67. }
  68. },
  69. "btTm":{
  70. "@attributes":{
  71. "id":"63",
  72. "sName":"KOL"
  73. },
  74. "Inngs":{
  75. "@attributes":{
  76. "desc":"Inns",
  77. "r":"66",
  78. "Decl":"0",
  79. "FollowOn":"0",
  80. "ovrs":"10.1",
  81. "wkts":"4"
  82. }
  83. }
  84. },
  85. "blgTm":{
  86. "@attributes":{
  87. "id":"58",
  88. "sName":"CHN"
  89. }
  90. }
  91. }
  92. }
  93. ]
  94. }';
  95. $obj = json_decode($json);
  96.  
  97. function objectToString($obj, $delimiter = PHP_EOL) {
  98. foreach($obj as $key=>$val) {
  99.  
  100. if(is_object($val) || is_array($val)) {
  101. objectToString($val, $delimiter);
  102. } else {
  103. echo $key . '=> ' .$val . $delimiter;
  104. }
  105. }
  106. }
  107.  
  108.  
  109.  
  110. objectToString($obj);
  111. ?>
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
NMchs=> 10
fUrlBase=> http://s...content-available-to-author-only...z.com/j2me/1.0/flags/team_
id=> 3
type=> T20
srs=> Indian Premier League 2013
mchDesc=> KOL vs CHN
mnum=> 26th Match
vcity=> Kolkata
vcountry=> India
grnd=> Eden Gardens
inngCnt=> 1
datapath=> http://s...content-available-to-author-only...z.com/j2me/1.0/match/2013/2013_T20_LEAGUE/KOL_CHN_APR20/
mchState=> inprogress
status=> KOL elect to bat
TW=> Kolkata
decisn=> Batting
addnStatus=> 
splStatus=> 
id=> 63
Name=> Kolkata
sName=> KOL
flag=> 0
id=> 58
Name=> Chennai
sName=> CHN
flag=> 0
Dt=> Apr 20 2013
stTme=> 10:30
enddt=> Apr 20 2013
noofovers=> 50
rrr=> 0
crr=> 6.49
cprtshp=> 11(13)
id=> 63
sName=> KOL
desc=> Inns
r=> 66
Decl=> 0
FollowOn=> 0
ovrs=> 10.1
wkts=> 4
id=> 58
sName=> CHN