I'm trying to access 3 variables from 3 different functions in a single function. They're all arrays. I want to foreach
them in that single function.
class poetry {
public function __construct() {
add_action( 'wp_head', array( $this, 'generate_scripts' ) );
}
public function page_one() {
$options = array(
array( 'content1', 'Content1', 'The Content 1'),
array( 'content2', 'Content2', 'The Content 2'),
array( 'content3', 'Content3', 'The Content 3'),
);
$this->add_settings( 'page_one', $options );
}
public function page_two() {
$options = array(
array( 'content4', 'Content4', 'The Content 4'),
array( 'content5', 'Content5', 'The Content 5'),
array( 'content6', 'Content6', 'The Content 6'),
);
$this->add_settings( 'page_two', $options );
}
public function page_three() {
$options = array(
array( 'content7', 'Content7', 'The Content 7'),
array( 'content8', 'Content8', 'The Content 8'),
array( 'content9', 'Content9', 'The Content 9'),
);
$this->add_settings( 'page_three', $options );
}
public function generate_scripts() {
// how do I access $options from the above functions in this function?
foreach($options as $option) {
echo $option[0];
}
}
}
How can I access all 3 $options
from the above functions and foreach the arrays in generate_scripts()
?