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

FluentDOM\Query::prepend()

FluentDOM\Query prepend(string|array|\DOMNode|\Traversable $selector);

Prepend content to the inside of every matched element.

Usage

$html = <<<HTML
<html>
  <head>
    <title>Examples: FluentDOM\Query::prepend()</title>
  </head>
  <body>
    <p> he said. </p>
  </body>
</html>
HTML;

echo FluentDOM($html)
  ->find('//p')
  ->prepend('<strong>Hello</strong>');

Output

<?xml version="1.0"?>
<html>
  <head>
    <title>Examples: FluentDOM\Query::prepend()</title>
  </head>
  <body>
    <p><strong>Hello</strong> he said. </p>
  </body>
</html>
Clone this wiki locally