What is [{ }] notation in php?

Member

by dedrick , in category: PHP General , a year ago

What is [{ }] notation in php?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by darrion.kuhn , 7 months ago

@dedrick 

In PHP, [{ }] notation allows you to create an array with one element, which is itself an empty array. It is a shorthand way of creating a nested array in one line.


For example:

1
2
$arr = [{}];
print_r($arr);


This will output:

1
2
3
4
5
6
Array
(
    [0] => Array
        (
        )
)


Related Threads:

How to write integers using binary notation in presto?
How to redirect after 5 seconds in PHP?
How to pass a variable from python 3 to php?
How to create json files from 3 php arrays?
How to throw exception in PHP?
How to read from a file in PHP?