2014-03-27 114 views
-1

任何人都可以請幫我解碼這個字符串?如何解碼用逗號和方括號編碼的數組?

[[["¡hola","hello","",""]],[["interjection", 
["¡Hola!","¡Caramba!","¡Oiga!","¡Diga!","¡Bueno!","¡Vale!","¡Aló!"],[["¡Hola!", 
["Hello!","Hi!","Hey!","Hullo!","Hallo!","Hoy!"],,0.70910621],["¡Caramba!", 
["Gee!","Well!","Good gracious!","Well I never!","By jingo!","By gum!"]],["¡Oiga!", 
["Listen!","Hello!","Hullo!","Hallo!","I say!","See here!"]],["¡Diga!", 
["Hello!","Hullo!","Talk away!"]],["¡Bueno!",["Well!","All 
right!","Hello!","Hallo!","Hullo!"]], 
["¡Vale!"["Okay!","OK!","O.K.!","Okey!","Hello!"]], 
["¡Aló!",["Hello!","Hullo!","Halliard!"]]],"Hello!",9]],"en",,[["¡hola", 
[1],true,false,999,0,2,0]],[["hello",1,[["¡hola",999,true,false], 
["Hola",0,true,false],["saludar",0,true,false],["saludo",0,true,false]], 
[[0,5]],"hello"]],,[,"Hello!",[10],,true], 
[],3] 

我試過json_decode但沒有運氣。

謝謝!

+1

因爲它不是有效的json。這個字符串來自哪裏? –

+0

你是對的。我收到了translate.google.com – rAjA

+0

的回覆,然後使用他們的[API](https://developers.google.com/translate/) –

回答

0

我已經找到了解決方案,將字符串轉換爲有效的JSON。希望這可以幫助某人。

$t = '[[["¡hola","hello","",""]],[["interjection", 
     ["¡Hola!","¡Caramba!","¡Oiga!","¡Diga!","¡Bueno!","¡Vale!","¡Aló!"],[["¡Hola!", 
     ["Hello!","Hi!","Hey!","Hullo!","Hallo!","Hoy!"],,0.70910621],["¡Caramba!", 
     ["Gee!","Well!","Good gracious!","Well I never!","By jingo!","By gum!"]],["¡Oiga!", 
     ["Listen!","Hello!","Hullo!","Hallo!","I say!","See here!"]],["¡Diga!", 
     ["Hello!","Hullo!","Talk away!"]],["¡Bueno!",["Well!","All 
     right!","Hello!","Hallo!","Hullo!"]], 
     ["¡Vale!"["Okay!","OK!","O.K.!","Okey!","Hello!"]], 
     ["¡Aló!",["Hello!","Hullo!","Halliard!"]]],"Hello!",9]],"en",,[["¡hola", 
     [1],true,false,999,0,2,0]],[["hello",1,[["¡hola",999,true,false], 
["Hola",0,true,false],["saludar",0,true,false],["saludo",0,true,false]], 
[[0,5]],"hello"]],,[,"Hello!",[10],,true], 
[],3]'; 

    $t = str_replace(',,',',"",',$t); 
    $t = str_replace('[,','["",',$t); 
    $t = str_replace(',]',',""]',$t); 
    $arr = json_decode($t); 
    print_r($arr);