-3

I have an external js array (which daily updated), here is the sample of the code:

var info = new Array(); 
info[0] = new Array('','England','','League One','BARNSLEY',35,4.9,23.6,67,181,'',36,'CHESTERFIELD',2.8,25.3,11,184,'',36,22,'','',28,2,4,0,4,3,3,1,4,3,4,2,0,7,2,3,3,2,2,0,0,3,0,1,3,1,3,3,5,2,5,' 11','6 ',55,25,25,30,30,30,4,2,1,2,2,2,2,3,2,3,2,2,3,2,2,2,2,2,2,2,2,2,1,2); info[1] = new Array('','Austria','','Bundesliga','WIENER NEUSTADT',213,6.0,25.2,34,181,'',30,'RIED',8.9,24.0,38,182,'',42,28,'','',28,3,0,2,1,2,0,4,4,0,3,2,1,4,3,5,2,0,3,0,2,3,0,3,0,3,1,3,5,2,5,' 9','6 ',30,30,30,30,30,35,2,2,2,2,2,2,2,2,0,2,2,2,1,2,2,1,2,2,3,2,2,1,2,2);info[2] = new Array('','England','','League One','DONCASTER',273,5.6,26.6,50,181,'',41,'ROCHDALE',3.4,25.3,23,182,'',31,27,'','',28,4,2,3,2,0,4,3,0,4,0,1,0,5,2,5,2,4,1,3,2,1,1,1,1,3,0,1,3,2,7,' 12','7 ',35,30,25,35,30,30,2,2,3,3,3,3,3,2,3,2,3,2,2,2,2,2,2,2,2,2,2,2,2,2); info[3] = new Array('','England','','League One','GILLINGHAM',342,2.4,24.3,32,182,'',33,'BRADFORD',6.1,27.1,41,181,'',39,27,'','',28,3,1,0,0,4,3,4,4,1,2,2,1,5,2,5,4,2,1,4,2,4,1,0,2,2,0,4,4,4,4,' 14','9 ',30,30,35,30,30,30,2,2,1,1,2,2,1,2,2,2,2,2,1,1,2,1,2,1,2,2,1,2,2,1); 

How could I add these arrays to mysql database? It is possible? I have no idea...

Liverpool
  • 119
  • 1
  • 8
  • 2
    You can encode it to JSON and ajax-post it to php-script, which decode and add to database. – umka May 22 '15 at 07:37
  • possible duplicate of [PHP- Decode JSON](http://stackoverflow.com/questions/19609354/php-decode-json) – Narendrasingh Sisodia May 22 '15 at 08:38
  • Uchica, I don't want to search in this array. I would like to add all elements of array to a mysql database. And I can't edit this js array, because it is on external server. I can't add extra lines like var jsonArray=JSON.stringify(info); console.log(jsonArray); I already tried to parse datas with simple html dom, but I can't solved this problem. – Liverpool May 22 '15 at 10:57
  • are you getting this array within PHP – Narendrasingh Sisodia May 22 '15 at 11:03
  • no, without php. And this is the main problem. I have only this js array and I need the informations because it is daily updated – Liverpool May 22 '15 at 11:06

1 Answers1

0

Make json of this array using :

var info = new Array();
     info[0] = new Array('','England','','League One','BARNSLEY',35,4.9,23.6,67,181,'',36,'CHESTERFIELD',2.8,25.3,11,184,'',36,22,'','',28,2,4,0,4,3,3,1,4,3,4,2,0,7,2,3,3,2,2,0,0,3,0,1,3,1,3,3,5,2,5,' 11','6 ',55,25,25,30,30,30,4,2,1,2,2,2,2,3,2,3,2,2,3,2,2,2,2,2,2,2,2,2,1,2); info[1] = new Array('','Austria','','Bundesliga','WIENER NEUSTADT',213,6.0,25.2,34,181,'',30,'RIED',8.9,24.0,38,182,'',42,28,'','',28,3,0,2,1,2,0,4,4,0,3,2,1,4,3,5,2,0,3,0,2,3,0,3,0,3,1,3,5,2,5,' 9','6 ',30,30,30,30,30,35,2,2,2,2,2,2,2,2,0,2,2,2,1,2,2,1,2,2,3,2,2,1,2,2);info[2] = new Array('','England','','League One','DONCASTER',273,5.6,26.6,50,181,'',41,'ROCHDALE',3.4,25.3,23,182,'',31,27,'','',28,4,2,3,2,0,4,3,0,4,0,1,0,5,2,5,2,4,1,3,2,1,1,1,1,3,0,1,3,2,7,' 12','7 ',35,30,25,35,30,30,2,2,3,3,3,3,3,2,3,2,3,2,2,2,2,2,2,2,2,2,2,2,2,2); info[3] = new Array('','England','','League One','GILLINGHAM',342,2.4,24.3,32,182,'',33,'BRADFORD',6.1,27.1,41,181,'',39,27,'','',28,3,1,0,0,4,3,4,4,1,2,2,1,5,2,5,4,2,1,4,2,4,1,0,2,2,0,4,4,4,4,' 14','9 ',30,30,35,30,30,30,2,2,1,1,2,2,1,2,2,2,2,2,1,1,2,1,2,1,2,2,1,2,2,1);
     var jsonArray=JSON.stringify(info);
     console.log(jsonArray);

Send this data using ajax call..

Rayon
  • 36,219
  • 4
  • 49
  • 76
  • I can't add extra lines to the js source because it is on external web address. I think this is impossible for me. But thanks for the answer, but I am not json expert. – Liverpool May 22 '15 at 08:34