dongrandi8411
2016-03-28 13:27
浏览 26
已采纳

如何使用php [duplicate]检索mysql中的星期几

This question already has an answer here:

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

</div>

图片转代码服务由CSDN问答提供 功能建议

此问题已经存在 这里有一个答案:

  • 如何使用php serialize()和unserialize() 10 answers

    星期几以下列格式存储: -

     <代码>一个:3:{I:0; S:6: “星期一”; I:1; S:9: “星期三”; I:2; S:6:” 星期五“;} 
       
     
     

    如何将其转换为可读格式并只显示 - 周一,周三和周五?

    我找不到与转换相关的任何内容,但是有很多文章用于存储使用不同方法的星期几。

    谢谢< / p>

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • doujing5435 2016-03-28 13:32
    已采纳

    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
    
    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题