1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

extracting part of a string

Discussion in 'PHP' started by Rasputin, Jun 20, 2008.

Thread Status:
Not open for further replies.
  1. #1
    Hi

    Each month I receive a travel related product feed in XML that I need to access and manipulate using PHP.

    Each record in this particular XML file contains an entry like:
    <name>[place] holiday reference 12345</name>

    at the moment I manually add a new field for every record in the XML file for the destination, like
    <destination>place</destination>
    which is just an extract of the existing field
    and then use...
    if($this-place==$destination) {...}
    where $this-place comes from somewhere else in the file
    so if for example $this-place is New York, and $destination is also new York, the record prints out

    Is there a way to directly access the 'place' name (New York etc) in the <name> field without having to manually add places for every record ie chop off the '[' and ']holiday reference 12345'? and just use the <name> field directly without manually adding hundreds of items?

    Cheers
     
    Rasputin, Jun 20, 2008 IP
  2. sarahk

    sarahk iTamer Staff

    Messages:
    29,016
    Likes Received:
    4,584
    Best Answers:
    124
    Trophy Points:
    665
    #2
    PHP5 comes with it's own suite of XML commands - are you using PHP4 or 5?
     
    sarahk, Jun 21, 2008 IP
  3. Rasputin

    Rasputin Peon

    Messages:
    1,511
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Sarah

    I rephrased this question at
    http://forums.digitalpoint.com/showthread.php?t=897080
    because I thought I'd made it sound more complicated than it is

    I haven't tested it yet but it looks like 'explode' was the function I needed

    (PHP5 and simplexml by the way)

    Cheers
     
    Rasputin, Jun 21, 2008 IP
Thread Status:
Not open for further replies.