Help with some simple regex.

Discussion in 'PHP' started by chuckd1356, Feb 27, 2008.

  1. #1
    So here's the deal.
    I'm pulling some nice xml out of a DB, and storing it in a variable. I then want to use regex to break it apart. This is what it will look like...
    
    //in the DB, 
    <workplace>
    <name>...</name>
    <years>...</years>
    </workplace>
    <workplace>
    ...
    </workplace> etc.
    
    $xml  = mysql_query(...irrelevant...); 
    
    
    
    PHP:
    Now I really suck with regex, and I'm not sure how to go about this.
    Basically, I want to be left with an associative array like so...
    
    $array = array(1 => array('name' => '...', 'years' => '...'), 2 => etc...);
    
    PHP:
    How can I go about this, a point in the right direction would be perfectly fine.
     
    chuckd1356, Feb 27, 2008 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    nico_swd, Feb 27, 2008 IP
  3. chuckd1356

    chuckd1356 Active Member

    Messages:
    770
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    70
    #3
    Damn dude, thanks. Much simpler.
     
    chuckd1356, Feb 27, 2008 IP
  4. jamesmoey

    jamesmoey Peon

    Messages:
    34
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Or xpath implementation in PHP.
     
    jamesmoey, Feb 27, 2008 IP