• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WP SITES

2662

Original Genesis Tutorials & 5000+ Guaranteed Code

Snippets

  • Support
  • Newsletter
  • Videos
  • Log in

Premium Member? - Request custom code

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

  • array in PHP

Reader Interactions

Leave a Reply Cancel reply

You must be logged in to post a comment.

Primary Sidebar

PHP Code

template_include

get_body_class

if else

array

class_exists

foreach

sprintf

add_action

printf

variable

Advertise · WPEngine · Genesis · Log in

  • How Premium Membership Works
  • Sign Up
  • Support
  • Subscription Details/Invoice
  • Tagged Tutorials
  • Access-Download Problems