@@ -500,9 +500,20 @@ $doc->find('div').removeClass('first');
500
500
self substituteWith(string|NodeList|\DOMNode|callable $input)
501
501
```
502
502
503
+ Replace each node in the current set with the contents provided.
504
+
503
505
##### Example
504
506
505
507
``` php
508
+ $doc = (new Document())->html('<p ><b >Hello</b > <b >World!</b ></p >');
509
+ echo $doc->find('b')->substituteWith(function($node) {
510
+ return '<em >' . $node->text() . '</em >';
511
+ });
512
+ ```
513
+
514
+ * Result:*
515
+ ``` html
516
+ <p ><em >Hello</em > <em >World!</em ></p >
506
517
```
507
518
508
519
---
@@ -513,9 +524,33 @@ self substituteWith(string|NodeList|\DOMNode|callable $input)
513
524
string|self text([string|NodeList|\DOMNode|callable $input = null])
514
525
```
515
526
516
- ##### Example
527
+ Get the text contents of the current set.
528
+
529
+ ##### Example (get)
517
530
518
531
``` php
532
+ $doc = (new Document())->html('<div class =" text" >Hello World!</div >');
533
+ echo $doc->find('.text')->text();
534
+ ```
535
+
536
+ * Result:*
537
+ ``` html
538
+ <div class =" second" ></div >
539
+ ```
540
+
541
+ Set the text contents for current set.
542
+
543
+ ##### Example (set)
544
+
545
+ ``` php
546
+ $doc = (new Document())->html('<div class =" text" ><string >The quick brown</strong > fox <em >jumps over the lazy dog</em ></div >');
547
+ $doc->find('.text')->text('Hello World!');
548
+ echo $doc->html();
549
+ ```
550
+
551
+ * Result:*
552
+ ``` html
553
+ <div class =" text" >Hello World!</div >
519
554
```
520
555
521
556
---
@@ -1092,6 +1127,8 @@ $slicedNodes = $nodes->slice(1, 3);
1092
1127
int count()
1093
1128
```
1094
1129
1130
+ Return number of nodes in the current set
1131
+
1095
1132
##### Example
1096
1133
1097
1134
``` php
@@ -1108,6 +1145,8 @@ echo $nodes->count();
1108
1145
self each(callable $function)
1109
1146
```
1110
1147
1148
+ Iterate through for each item in the existing set via callback
1149
+
1111
1150
##### Example
1112
1151
1113
1152
``` php
0 commit comments