Unclutter array definitions in PHP
Here's a little trick how to print definitions of large arrays in a more beatiful way. Instead of passing a set of strings to the array() function, pass only one string to the explode() function!
For example, consider a section in the WordPress code (/wp-includes/post.php):
PHP:
-
// currently
-
'post_content', 'post_content_filtered', 'post_title', 'post_excerpt',
-
'post_status', 'post_type', 'comment_status', 'ping_status',
-
'post_password', 'post_name', 'to_ping', 'pinged', 'post_modified',
-
'post_modified_gmt', 'post_parent', 'menu_order', 'guid' ) );
-
-
// equals
-
'post_content_filtered|post_title|post_excerpt|post_status|post_type|'.
-
'comment_status|ping_status|post_password|post_name|to_ping|pinged|'.
-
'post_modified|post_modified_gmt|post_parent|menu_order|guid' ) );
Not only is the second part shorter, but it is also easier to edit and to overview. Of course this always depends on how many elements your array has; it's rather ridiculous with small arrays.

