In my table column i have 2 formats data:
A version) incorrect format records in table (column: mylinks > longtext > DC2Type:array) - approximately 1330 records:
a:4:{s:7:"content";s:11:"link 1 name";s:3:"url";s:17:"https://link1.com";i:2;s:11:"link 2 name";i:3;s:17:"https://link2.com";}
B version) correct format records in table (column: mylinks > longtext > DC2Type:array) - approximately 3200 records:
a:4:{i:0;s:11:"link 1 name";i:1;s:17:"https://link1.com";i:2;s:11:"link 2 name";i:3;s:17:"https://link2.com";}
And in my twig file i read this as:
{% if requirement.mylinks|length == 2 %} - <a href="{{ requirement.mylinks|last }}" target="_blank">{{ requirement.mylinks|first|raw }}</a> {% elseif requirement.mylinks|length == 4 %} - <a href="{{ requirement.mylinks[1] }}" target="_blank">{{ requirement.mylinks|first|raw }}</a><br /><br /> - <a href="{{ requirement.mylinks|last }}" target="_blank">{{ requirement.mylinks[2]|raw }}</a> {% elseif requirement.mylinks|length == 6 %} - <a href="{{ requirement.mylinks[1] }}" target="_blank">{{ requirement.mylinks|first|raw }}</a><br /><br /> - <a href="{{ requirement.mylinks[3] }}" target="_blank">{{ requirement.mylinks[2]|raw }}</a><br /><br /> - <a href="{{ requirement.mylinks|last }}" target="_blank">{{ requirement.mylinks[4]|raw }}</a>
Of course when if transform my B version data then everything is ok. But when if transform my A version data then it dont work and dont display correctly links.
My question is:Is it possible to read the A version data correctly in this situation only using Twig (while still displaying the B version)? If not, what are my options? If I have to read incorrect data formats in PHP, what is the best way to do it so that I can later easily display both data formats in Twig?
I will be grateful for constructive help