Query InsertBefore - ThomasWeinert/FluentDOM GitHub Wiki
FluentDOM\Query insertBefore(string|array|\DOMNode|\Traversable $selector);
Insert all of the matched elements before another, specified, set of elements.
$html = <<<HTML
<html>
<head>
<title>Examples: FluentDOM\Query::insertBefore()</title>
</head>
<body>
<div id="foo">FOO!</div><p>I would like to say: </p>
</body>
</html>
HTML;
echo FluentDOM($html)
->find('//p')
->insertBefore('//div[@id = "foo"]');
<?xml version="1.0"?>
<html>
<head>
<title>Examples: FluentDOM\Query::insertBefore()</title>
</head>
<body>
<p>I would like to say: </p><div id="foo">FOO!</div>
</body>
</html>