Building an array from page titles

Hello,

I am using the following array:

<? $countries = array('greece', 'united-kingdom', 'italy', 'germany'...);

However i would like to build the same array dynamically.

Obviously the following code is not working but is just to illustrate what i am trying to do.

<?php $countries = array(page('countries')->children()->title()) ?>

If anybody could help me with that, it would be much appreciated!

You can use the pluck()method:

$countries = page('countries')->children()->pluck('title');
1 Like

Lifesaver! :slight_smile: