Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    May 2013
    Location
    KGFK
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Echo Portion of XML

    I'm guessing there is a better way to do this and would like some assistance, I am still fairly new to PHP.

    I've got an XML file that outputs:

    <entry>
    <updated>2017-05-14T22:18:23Z</updated>
    <title>Fleet Alignment</title>
    </entry>

    I would like to list the month and day that the post was created along with the title; ex: MM-DD "Title".

    I've got it working with this code: <?php echo substr($news->updated,6,4); ?> <a href="<?php echo $news->link['href'];?>"><?php echo $news->title. PHP_EOL .'<br><br></a>';

    Is substring the correct way to do this? Is there a better way?

    Thanks for any suggestions, the XML is coming from a simple machines forum installation.

  2. #2
    Master Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    5,820
    Thanks
    26
    Thanked 603 Times in 596 Posts
    Is there a better way?
    PHP: Date/Time - Manual
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •