Try this instead:
function settings_sections() {
// array containing settings identifiers
$array = ( 'SOMETHING', 'SOMETHING2', 'SOMETHING3', 'SOMETHING4' );
// loop through settings identifiers and generate settings sections
foreach( $array as $v) {
add_settings_section(
$v . '_settings',
$v . ' Settings',
'generate',
$v . '_page'
);
}
}
echo
outputs a string, you should just be calling add_settings_section()
directly from inside the loop.
Also, NB: generate()
is not the best name for a function, you should really go with something that’s less likely to overlap with another function (prefix it with something)