php - xml - random filter and store the order

前端 未结 1 895
萌比男神i
萌比男神i 2021-01-22 14:34

PHP: I get XML feed of 20 articles, I have pick 3 articles randomly and print xml out in the same format. Randomly picked article should change random every day not on every ref

1条回答
  •  一向
    一向 (楼主)
    2021-01-22 14:54

    How about just save your file with a date name and then check that date doesn't already exist

    // Write our updated XML back to a new file
            if( !file_exists( $date . '_feedout.xml' ) )
                $doc->save( $date . '_feedout.xml' );
    

    Or

     // Write our updated XML back to a new file
                if( date( "Y/m/d", filemtime( 'feedout.xml' ) ) != $date )
                    $doc->save( 'feedout.xml' );
    

    0 讨论(0)
提交回复
热议问题