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

FluentDOM\Query::before()

FluentDOM\Query before(string|array|\DOMNode|\Traversable|callable $content);

Insert content before each of the matched elements.

Usage

$html = <<<HTML
<html>
  <head>
    <title>Examples: FluentDOM\Query::before()</title>
  </head>
  <body>
    <p> is what I said...</p>
  </body>
</html>
HTML;

echo FluentDOM($html)
  ->find('//p')
  ->before(' World')
  ->before('<b>Hello</b>');

Output

<?xml version="1.0"?>
<html>
  <head>
    <title>Examples: FluentDOM\Query::before()</title>
  </head>
  <body>
    <b>Hello</b> World<p> is what I said...</p>
  </body>
</html>
Clone this wiki locally