This is more a generic PHP question than anything to do with WordPress, but I’d suggest setting the value in the constructor:
class test {
public $basicCols;
public $optList = array( 'one' => 'One', 'two' => 'Two' );
function __construct() {
$this->basicCols = array(
array( 'title' => 'KEY', 'field' => 'slug', 'options' => $this->optList ),
array( 'title' => 'KEY', 'field' => 'slug' )
);
}
}
Related Posts:
- How to store the_title() into a variable to reutrn the value, not just echo it
- Using a variable in is_page(array())
- Call global variable array() in woocommerce child/template
- How to access or parse key/values that have “string”
- Dynamically adding filters
- How to add elements to an empty array in PHP?
- Pass a PHP variable to another file
- Sorting list of sites from multisite network using wp_get_sites
- How do I make my function add variables/values to the $post object?
- How to update single value in multi dimensional Post Meta?
- How do I know what variables are passed in a filter/action and what their meaning is?
- Looping through WP_Post Object
- Using a javascript file to access a get posts array
- Generate an array of parent/child page IDs, based on parent page name
- How do I output a database option that is an array into a get_posts array?
- How do I dynamically generate args for wp_query?
- Parsing php string in jquery [closed]
- Pass PHP variable to JavaScript without inline JS
- Count the number of times the search form template gets included on a page
- Working with query_posts ( arrays and query strings)
- How to properly loop through these external URLs to get them into the sitemap using this hook
- Recent posts with featured image or fallback image with permalink
- Storing Array from returned database query and using the array in a new query
- Populate dropdown with Child Pages based on Parent Page chosen
- Get value from shortcode to do something
- PHP Array Returning [object Object]. Tried existing answers results with no luck
- Exclude posts based on meta value
- Alter required message using comment form api
- Advanced Custom Fields – display label and value only if value entered
- wp_force_remove_style’ not found
- How can I access string value in an array?
- How to use if statement in an array? [closed]
- How to array only one key from another array
- Filtering a function’ output for a new continued function
- WordPress function and string as variable?
- Create a WordPress shortcode using PHP [duplicate]
- Why is an array created in a function hooked to customize register populated when customizer is loaded but not when the front-end is loaded?
- Get categories names as an array to use it in theme settings
- Get access to variable from previous pageview, excluding ajax-calls
- How to get the last category name of a child category?
- Foreach loop inside an array_merge
- Pass Variables or Variable Place-Holder from Editor to PHP
- If Array Values Match Another Array’s Values, Then
- WordPress loop by meta key that is an array? and how loop multiple arrays
- How Do I Find & Remove H1 From Site-Title-Wrapper? [closed]
- Getting posts to exclude from array
- I’m unable to call img path using single quotes in an array?
- Comapare get_user_meta value
- How can get all users by current user meta?
- Get the id of all images in a post
- Output category list inside array
- how to make an array of post id’s in is_single
- Store and Change Session variable – PHP SESSION VARIABLE
- array_rand not working correctly?
- Overide Variable in Child Theme
- Get css class of menu item in custom menu structure
- WordPress call post-ID in jquery
- How To Pass Array To get_the_category_by_ID() and Get An Array Back?
- PHP variables in a post?
- Add custom fields from different posts
- Unable to display multiple parameters from url by javascript through shortcodes
- Sending simple variable on single page to WP JSON
- Order users by random not working?
- How to check a variable Changes
- in_array not working on dev server but works on localhost
- global $product is empty string when passed into function
- How can I show how much water got saved on this order (making use of the number of items bought) on a thank-you-page?
- Trying to add some custom text into WordPress Post title via function.php
- How to display MySQL table data which is stored as an array?
- Reduce Stock Based on Custom Variation Field Rather than Attribute (Working Script)
- How to change the value of a variable using input field?
- Show the subcategory name based on current product
- How to filter specific element of an array in wordpress/php?
- How to find php variable of wordpress theme settings
- Notice : Array to string conversion on array_intersect user meta
- Remove item from post_meta array via AJAX
- Make sticky post with FacetWP
- Add class to all meta boxes for a custom post type
- Fatal error when using array_diff() function inside of wp_update_nav_menu hook?
- PHP array to jQuery array ” Uncaught SyntaxError: Unexpected token < "
- Display posts using post ID’s in an array
- Passing parameter from the current URL to redirect to another url
- Undefined variable & issue with smof_data
- Display a single row from nested array of custom field data
- Pulling a variable into the wp_nav_menu function
- How to use foreach and if statement within array of arrays?
- How to find the function which is outputting Array
- Create Customization Controls from Array
- Exclude Post ID from Array Specified in Custom Field
- Create and update Custom Cookie based on multiple GET and POST Values for first time visitors?
- !in_array doesnt recognize category
- How to set if meta_value is lower < than other meta_value in a get_posts array?
- Shortcode not passing variable to included file
- ACF allow zero as a value
- Can’t get options with $data[‘variable’]
- Populate checkboxes from array
- Why is my array_diff usage breaking things?
- Grabbing value of input field inside of array
- How to group by column a and sum column b and c in a php array
- PHP how to submit array elements to database