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 Create Quiz Comment G gurrrung Follow 0 Improve G gurrrung Follow 0 Improve Article Tags : Web Technologies PHP PHP-function PHP-DOM Explore BasicsPHP Syntax4 min readPHP Variables5 min readPHP | Functions6 min readPHP Loops4 min readArrayPHP Arrays5 min readPHP Associative Arrays4 min readMultidimensional arrays in PHP5 min readSorting Arrays in PHP4 min readOOPs & InterfacesPHP Classes2 min readPHP | Constructors and Destructors5 min readPHP Access Modifiers4 min readMultiple Inheritance in PHP4 min readMySQL DatabasePHP | MySQL Database Introduction4 min readPHP Database connection2 min readPHP | MySQL ( Creating Database )3 min readPHP | MySQL ( Creating Table )3 min readPHP AdvancePHP Superglobals6 min readPHP | Regular Expressions12 min readPHP Form Handling4 min readPHP File Handling4 min readPHP | Uploading File3 min readPHP Cookies9 min readPHP | Sessions7 min read Like