douliudong8108 2012-12-16 13:02
浏览 30
已采纳

改变从美国格式到英国的数组元素

I am pulling in movie data from an external API to create a database similar to IMDb for my final year university project, and the release date information is formatted as YYYY-MM-DD (i.e 16 December 2012 is displayed as 2012-12-16, rather than 16-12-2012). Is there any way to reorder the segments of the array to reshuffle them for a British English audience?

The raw result of the release date is as follows, gleaned from the getMovieReleases function in the TMDb API (N.B. to save on post size, I've only copied in the first 10 results from the getMovieReleases function):

[id] => 17578
    [countries] => Array
        (
            [0] => Array
                (
                    [iso_3166_1] => US
                    [certification] => PG
                    [release_date] => 2011-12-21
                )

            [1] => Array
                (
                    [iso_3166_1] => DE
                    [certification] => 6
                    [release_date] => 2011-10-27
                )

            [2] => Array
                (
                    [iso_3166_1] => FR
                    [certification] => 
                    [release_date] => 2011-10-26
                )

            [3] => Array
                (
                    [iso_3166_1] => TR
                    [certification] => 
                    [release_date] => 2011-11-04
                )

            [4] => Array
                (
                    [iso_3166_1] => DK
                    [certification] => 7
                    [release_date] => 2011-10-27
                )

            [5] => Array
                (
                    [iso_3166_1] => GB
                    [certification] => PG
                    [release_date] => 2011-10-26
                )

            [6] => Array
                (
                    [iso_3166_1] => FI
                    [certification] => 12
                    [release_date] => 2011-11-04
                )

            [7] => Array
                (
                    [iso_3166_1] => IT
                    [certification] => T
                    [release_date] => 2011-10-28
                )

            [8] => Array
                (
                    [iso_3166_1] => SE
                    [certification] => 
                    [release_date] => 2011-10-28
                )

            [9] => Array
                (
                    [iso_3166_1] => NL
                    [certification] => 6
                    [release_date] => 2011-10-26
                )

            [10] => Array
                (
                    [iso_3166_1] => BE
                    [certification] => 
                    [release_date] => 2011-10-26
                )
        )

)

I am calling the data in my PHP & HTML as follows, only picking out the US and UK release dates:

$releases = $tmdb->getMovieReleases($tmdb_id);

$uk = $releases['countries']['14']['release_date'];
$us = $releases['countries']['0']['release_date'];

<section>
    <p class="title">RELEASE DATE</p>
    <p class="section_body">
        <?php echo $uk; ?> (UK)<br>
        <?php echo $us; ?> (US)
    </p>
</section>
  • 写回答

2条回答 默认 最新

  • doutuan9357 2012-12-16 13:09
    关注
    $uk = date('d/m/Y', strtotime($releases['countries']['14']['release_date']));
    

    That should point you in the right direction..

    see date() and strtotime()

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c