Jump to content

blinks

Members
  • Posts

    53
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

blinks's Achievements

Member

Member (2/5)

0

Reputation

  1. Did it; set second $fieldNodeList to $fieldNodeList->item(0)->setAttribute('type', 'test'); :-)
  2. I have a series of xml files, which contain the line: <para type="series"> which I want to change to <para type="test"> I'm using the following code for an individual file, but the change is not happening. Any advice appreciated. $doc = DOMDocument::loadXML($xmlString); $xpath = new DOMXPath($doc); $fieldNodeList = $xpath->query("/para"); $fieldNodeList->setAttribute('type', 'test'); $newXML = $doc->SaveXML();
  3. Smoseley, thanks so much. That did the trick! And thanks, Pikachu2000 for that reformatting :-)
  4. Smoseley, thanks for your reply. Unfortunately array_merge doesn't do what I want, as it simply appends one array after the other. Apologies for my arrays being so badly formatted and hard to read. What I want to do is merge the arrays so that keys/values that exist in both arrays are retained; and where a key exists in both arrays, also retain all values in both arrays.
  5. I have 2 arrays: Array1= ([0] => Array ( [id] => 521 [countA] => 2 [dateA] => 2011-11-07 ) [1] => Array ( [id] => 647 [countA] => 5 [dateA] => 2011-12-07 ) [2] => Array ( [id] => 660 [countA] => 1 [dateA] => 2011-11-03 )) Array2= ( [0] => Array ( [id] => 321 [countB] => 2 [dateB] => 2011-12-07 ) [1] => Array ( [id] => 645 [countB] => 5 [dateB] => 2011-11-01 ) [2] => Array ( [id] => 660 [countB] => 1 [dateB] => 2011-12-07 )) which I want to combine into a single array: Result= ( [0] => Array ( [id] => 321 [countA] => [dateA] => [countB] => 2 [dateB] => 2011-12-07 ) [1] => Array ( [id] => 521 [countA] => 2 [dateA] => 2011-11-07 [countB] => [dateB] => ) [2] => Array ( [id] => 645 [countA] => [dateA] => [countB] => 5 [dateB] => 2011-11-01 ) [3] => Array ( [id] => 647 [countA] => 5 [dateA] => 2011-12-07 [countB] => [dateB] => ) [4] => Array ( [id] => 660 [countA] => 1 [dateA] => 2011-11-03 [countB] => 1 [dateB] => 2011-12-07 )) Is it possible to do this via something like array_diff, without having to loop through the arrays?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.