Search code examples
phparraysstring-interpolation

What do [], @ and {} mean in the context of this associative array declaration?


I have the following code

$arr =  array(
     'media[]'  => "@{$image};type=image/jpeg;filename={$image}"
);

I do not know what line 2 means. What do the [], @ and {} stand for?

UPDATE:

This is a code extracted from Upload images on Twitter using PHP.

Used to upload images to Twitter. I need to implement the same in Lua. Hence this question.


Solution

  • $arr =  array(
         'media[]'  => "@{$image};type=image/jpeg;filename={$image}",
    );
    

    is just like

    $arr =  array(
         'media[]'  => "@".$image.";type=image/jpeg;filename=".$image,
    );
    

    See the PHP manual for what the curly brackets ({}) mean in double-quoted strings.

    And for "[]" and "@" they are just normal strings.