PHP | DOMText splitText() Function Last Updated : 13 Mar, 2020 Comments Improve Suggest changes Like Article Like Report The DOMText::splitText() function is an inbuilt function in PHP which is used to break a node into two nodes at the specified offset. Syntax: DOMText DOMText::splitText( int $offset ) Parameters: This function accepts a single parameter $offset which holds the offset to split. Return Value: This function returns a new node of the same type, which contains all the content at and after the offset. Below given programs illustrate the DOMText::splitText() function in PHP: Program 1: php <?php // Create the text Node $text = new DOMText('GeeksforGeeks'); // Split the text $splitedtext = $text->splitText(8); echo $splitedtext->nodeValue; ?> Output: Geeks Program 2: php <?php // Create a new DOMDocument instance $document = new DOMDocument(); // Create a div element $element = $document->appendChild(new DOMElement('div')); // Create a text Node $text = $document->createTextNode('GeeksforGeeks'); // Append the nodes $element->appendChild($text); echo "Number of text nodes before splitting: "; echo count($element->childNodes) . "<br>"; // Splitting the text $text->splitText(5); echo "Number of text nodes after splitting: "; echo count($element->childNodes); ?> Output: Number of text nodes before splitting: 1 Number of text nodes after splitting: 1 Reference: https://www.php.net/manual/en/domtext.splittext.php Comment More infoAdvertise with us Next Article PHP | DOMText splitText() Function G gurrrung Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-DOM Similar Reads PHP mb_split() Function The mb_split() is an inbuilt PHP function that split the multibyte strings with help of the regular expression. Syntax: mb_split(pattern,string,limit): array|falseParameters: Â This function accepts 3 parameters: pattern: In this parameter, we define a regular expression that helps us to split a stri 1 min read PHP | DOMDocument saveXML() Function The DOMDocument::saveXML() function is an inbuilt function in PHP which is used to create an XML document from the DOM representation. This function is used after building a new dom document from scratch. Syntax: string DOMDocument::saveXML( DOMNode $node, int $options = 0 ) Parameters: This functio 2 min read PHP DOMDocument saveHTML() Function The DOMDocument::saveHTML() function is an inbuilt function in PHP that is used to create an HTML document from the DOM representation. This function is used after building the dom document from scratch. Syntax: string DOMDocument::saveHTML( DOMNode $node = NULL ) Parameters: This function accepts s 2 min read PHP | simplexml_import_dom() Function The simplexml_import_dom() function is an inbuilt function in PHP which is used to take a node of DOM document and convert it into a SimpleXML node. Syntax: SimpleXMLElement simplexml_import_dom( $node, $class_name = "SimpleXMLElement" ) Parameters: This function accepts two parameters as mentioned 1 min read PHP | SplFileObject fgetss() Function The SplFileObject::fgetss() function is an inbuilt function of Standard PHP Library (SPL) in PHP which is used to get line from file and strip HTML tags.Syntax:Â Â string SplFileObject::fgetss( $tags) Parameters: This function accept only one parameter $tags an optional parameter to specify tags whic 1 min read Like