M
M
Max Payne2015-02-08 21:55:09
PHP
Max Payne, 2015-02-08 21:55:09

Why does Illegal string offset 'response' occur?

As a result of uploading a photo to VK and transferring the json string to an array, I get the following array:

Array
(
    [response] => Array
        (
            [0] => Array
                (
                    [pid] => тутphotoID
                    [id] => тутID
                    [aid] => -14
                    [owner_id] => тутмойid
                    [src] => тутссылко
                    [src_big] => тутbig
                    [src_small] => тутsmall
                    [src_xbig] => тутxbig
                    [src_xxbig] => тутxxbig
                    [width] => 1000
                    [height] => 1000
                    [text] => 
                    [created] => 1423418012
                )

        )

)

When I try to get the ID( $get['response'][0]['id']) value, I get the following error:
Warning: Illegal string offset 'response' in /home/u748444830/public_html/html/Project1/wot4.php on line 18
Warning: Illegal string offset 'id' in /home/u748444830/public_html/html/Project1/wot4.php on line 18

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Melkij, 2015-02-08
@YardalGedal

So you are trying to access a string variable, not an array.
Check for typos, where is your json string and where is the decoded array.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question