Json

GatuZa

Новичок
Люди помогите пожалуйста!
есть массив
array(1) {
["images"]=>
array(4) {
[0]=>
array(5) {
["id"]=>
string(1) "1"
["before"]=>
string(12) "1-before.jpg"
["after"]=>
string(11) "1-after.jpg"
["comment"]=>
string(14) "Somebody Foto!"
["thumbs"]=>
string(16) "1-after-mini.jpg"
}
[1]=>
array(5) {
["id"]=>
string(1) "2"
["before"]=>
string(12) "2-before.jpg"
["after"]=>
string(11) "2-after.jpg"
["comment"]=>
string(14) "Somebody Foto!"
["thumbs"]=>
string(16) "2-after-mini.jpg"
}
[2]=>
array(5) {
["id"]=>
string(1) "3"
["before"]=>
string(12) "3-before.jpg"
["after"]=>
string(11) "3-after.jpg"
["comment"]=>
string(14) "Somebody Foto!"
["thumbs"]=>
string(16) "3-after-mini.jpg"
}
[3]=>
array(5) {
["id"]=>
string(1) "5"
["before"]=>
string(12) "4-before.jpg"
["after"]=>
string(11) "4-after.jpg"
["comment"]=>
string(14) "Somebody Foto!"
["thumbs"]=>
string(16) "4-after-mini.jpg"
}
}
}

применяю. к нему jsone_encode
string(460) "{"images":[{"id":"1","before":"1-before.jpg","after":"1-after.jpg","comment":"Somebody Foto!","thumbs":"1-after-mini.jpg"},{"id":"2","before":"2-before.jpg","after":"2-after.jpg","comment":"Somebody Foto!","thumbs":"2-after-mini.jpg"},{"id":"3","before":"3-before.jpg","after":"3-after.jpg","comment":"Somebody Foto!","thumbs":"3-after-mini.jpg"},{"id":"5","before":"4-before.jpg","after":"4-after.jpg","comment":"Somebody Foto!","thumbs":"4-after-mini.jpg"}]}"

передаю в шаблон, вставляю это все в ява-скрипт:
PHP:
var data = "<?=$pic?>";
выводит:
PHP:
     var data = "{"images":[{"id":"1","before":"1-before.jpg","after":"1-after.jpg","comment":"Somebody Foto!","thumbs":"1-after-mini.jpg"},{"id":"2","before":"2-before.jpg","after":"2-after.jpg","comment":"Somebody Foto!","thumbs":"2-after-mini.jpg"},{"id":"3","before":"3-before.jpg","after":"3-after.jpg","comment":"Somebody Foto!","thumbs":"3-after-mini.jpg"},{"id":"5","before":"4-before.jpg","after":"4-after.jpg","comment":"Somebody Foto!","thumbs":"4-after-mini.jpg"}]}";
скрипт не работает, думаю из-за кавычек, как убрать кавычки что после var data = ??? Должно быть var data = {"images" ... ? Помогитие плз.
 
Сверху