WP SITES

3082 Coded Tutorials & 284 Plugins

Code array() With [ ] Square Brackets

As of PHP 5.4 you can also use short array syntax, which replaces array() with [ ] square brackets.

Example:

The 1st example codes the array function for 2 custom post types named listing and portfolio using array().

array( 'listing','portfolio' );

You can now code the array using square brackets like this:

['listing','portfolio'];

If you’re learning PHP, at some stage you’ll come across PHP code which codes arrays using square brackets.

Related Tutorials

Leave a Reply

New Plugins