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

WP SITES

2784

Original Genesis Tutorials & 6000+ Guaranteed Code

Snippets

  • Consultation
  • Full Access
  • Log in

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

Code written by Brad Dalton specialist for Genesis, WooCommerce & WordPress theme customization. Read More…

Advertise · WPEngine · Genesis · Log in

  • Access Problems
  • Account Details
  • Consulting
  • Tags