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>
  • 写回答

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
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序