0

The Days of week is being stored in the following format :-

a:3:{i:0;s:6:"Monday";i:1;s:9:"Wednesday";i:2;s:6:"Friday";}

How can I convert it to a readable format and just display - Monday, Wednesday and Friday?

I couldn't find anything related to conversion but a lot of articles are there for storing the days of week using different approaches.

Thanks

Stacy J
  • 2,721
  • 15
  • 58
  • 92

1 Answers1

1

Use unserialize() for that to convert the string into array:

<?php
    $str = 'a:3:{i:0;s:6:"Monday";i:1;s:9:"Wednesday";i:2;s:6:"Friday";}';
    $arr = unserialize($str);

    print_r($arr);

    foreach($arr as $day){
        echo $day.'<br>';
    }
?>

output:

Array
(
    [0] => Monday
    [1] => Wednesday
    [2] => Friday
)

Monday
Wednesday
Friday
mitkosoft
  • 5,262
  • 1
  • 13
  • 31