Dynamically Generate Functions and Hooks

Since Milo is a genius, I got this done much simpler by just looping through the array inside of the function, instead of trying to generate a new function dynamically for each item. The array contains ‘slug’ and ‘title’ attributes, and here’s the function:

function cx_product_field() {
    global $fieldset;
    foreach ( $fieldset as $field ){
        woocommerce_wp_text_input(
            array( 
                'id' => 'cx_'.$field['slug'], 
                'class' => 'wc_input_text', 
                'label' => __( $field['title'], 'woocommerce' )
            ) 
        );
    }
}