mel47 Posted September 2, 2024 Share Posted September 2, 2024 Hi, I try to code something I've already done in another context, but since field is a text than a page, it seems to doesn't work exactly the same. foreach ($prize as $awardees) { $year = $awardees->year; //Problem is here; I got many times each year echo <h3>{$year}</h3>; //output : 2024 2023 2023 $allbyYear = wire('pages')->find("has_parent=1153, year=$year"); foreach ($allbyYear as $winner) { echo $winner->title; // output winner1 winner 2 winner 3 winner 2 winner 3 } } How I could only have 2024 and 2023? Thanks Melanie Link to comment Share on other sites More sharing options...
Nicolas Posted September 2, 2024 Share Posted September 2, 2024 Hi, You may find a soltution to your problem here : Hope this helps. Link to comment Share on other sites More sharing options...
TomPich Posted September 2, 2024 Share Posted September 2, 2024 Hi @mel47, I would split the string with duplicate dates into an array, then use array_unique to get rid of them, then join the array into a string Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now