www.webdeveloper.com
Results 1 to 2 of 2

Thread: array_intersect_key() on sub array value?

  1. #1
    Join Date
    Sep 2006
    Posts
    213

    array_intersect_key() on sub array value?

    I have two xml files, "events.xml" and "items.xml"...
    Code:
    <events>
       <event>
          <title>First Event</title>
          <itemids>1,2</itemids>
       </event>
    </events>
    
    <items>
       <item>
          <title>item1</title>
          <id>1</id>
       </item>
       <item>
          <title>item2</title>
          <id>2</id>
       </item>
       <item>
          <title>item3</title>
          <id>3</id>
       </item>
       <item>
          <title>item4</title>
          <id>4</id>
       </item>
    </items>
    I'm using simplexml to load both files, ultimately I'm trying to parse it as if were one file like this...
    Code:
    <events>
       <event>
          <title>First Event</title>
          <items>
             <item>
                <title>item1</title>
                <id>1</id>
             </item>
             <item>
                <title>item2</title>
                <id>2</id>
             </item>
          </items>
       </event>
    </events>
    I'm thinking I need to use array_intersect_key() but on the item->id, not the item key.

  2. #2
    Join Date
    Sep 2006
    Posts
    213
    Still no luck. I'm looking for an xml option to do this...
    Code:
    SELECT * FROM `items` WHERE `id` IN ($itemids)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles