Skip to content
Advertisement

php loop show current year data if not found instead of skiping

So I have a loop within a loop both have year data and I’m trying to figure out how to show current year (2021) data if years don’t match or exist on loop instead of using continue to skip the entry, any ideas or solutions are appreciated.

LIVE CODE: http://sandbox.onlinephpfunctions.com/code/b7cbef0613636aa41a41a7d5f283a2569ece9cb0

JavaScript

So this is the OUTPUT I get:

JavaScript

And this is the result I’m looking for:

JavaScript

Advertisement

Answer

Judging from the answers and the comments to them, it seems perhaps you are looking for something like this:

JavaScript

Output:

JavaScript

Demo on 3v4l.org

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement