I am trying to educate myself more on arrays and foreach statements.
In one file I have the following class and function:
class Onboarding_Dashboard {
static function dashboard_onboarding_content() {
$items = array(
'stage-1' => array(
'title' => 'Hello',
'content' => 'This is some content text',
'show-next' => 'true',
'show-prev' => 'true',
),
'stage-2' => array(
'title' => 'Hello',
'content' => 'This is some content text',
'show-next' => 'true',
'show-prev' => 'true',
)
)
}
}
In another file I'd like to use the content of this to create a foreach statement. Something like this:
static function action_get_content() {
$items = Onboarding_Dashboard::dashboard_onboarding_content();
foreach ($items as $item) {
echo '<h2>'.$item['title'].'</h2>';
echo '<p>'.$item['content'].'</p>';
}
}
But I'm not sure what else I need to add in order to get the data from my Class function dashboard_onboarding_content
UPDATE: I've updated my foreach statement, and wrapped it in a function. How do I cho the reults of this function at another point in my code - is it as simple as doing
echo action_get_content();