Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

This question already has an answer here:

I have a JavaScript array like this:

var f3_masks = [
    [
        {id: 0, id_name: '1-1', db_id: '3193586'},
        {id: 10, id_name: '3-4', db_id: '3193636'},
        {id: 20, id_name: '3-5', db_id: '3193636'}
    ],
    page2_fl = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],

    page2_fr = [
        './images/korpus1/floors/floor_3.jpg'
    ]
];

var f4_masks = [
    [
        {id: 0, id_name: '1-1', db_id: '3193586'},
        {id: 10, id_name: '3-4', db_id: '3193636'},
        {id: 20, id_name: '3-5', db_id: '3193636'}
    ]
];

etc. It's a pretty large set of arrays with thousands of strings. Part of it I can parse as JSON, but only part of it. What is the best way to read such JavaScript arrays without a regular stucture in PHP?

share|improve this question

marked as duplicate by mario, hjpotter92, cryptic ツ, EdChum, Soner Gönül Apr 13 '13 at 10:54

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
Didn't vote down, but that looks like a syntax error. –  Daedalus Apr 12 '13 at 22:41
    
JSON will work for you –  Mohsen Apr 12 '13 at 22:42
    
How wouild it work? It is not valid JSON array. –  Taras Bulgakov Apr 12 '13 at 22:50
    
Mario, thank you. Very similar questions, but not exactly my case. I have a set of vars, not just one. –  Taras Bulgakov Apr 12 '13 at 22:59

1 Answer 1

Keys must be in double quotes:

"page2_fl"

Try to use the checking service at http://jsonlint.com/.

share|improve this answer
    
I cannot change format of this array. I need to parse it in PHP as is. –  Taras Bulgakov Apr 12 '13 at 22:55

Not the answer you're looking for? Browse other questions tagged or ask your own question.