Skip to content
Thomas Weinert edited this page Jul 29, 2014 · 1 revision

FluentDOM\Nodes::unique()

array unique(array $array);

Sorts an array of DOM nodes based on document position, in place, with the duplicates removed. Note that this only works on arrays of DOM nodes, not strings or numbers.

Usage

$fd = new FluentDOM\Nodes(
  '<items><one/><two/><three/></items>'
);

$list = array_merge(
  $fd->find('/items/*')->toArray(),
  $fd->find('//*')->toArray()
);

var_dump(count($list), count($fd->unique($list)));

Output

int(7)
int(4)
Clone this wiki locally