# \[PHP\] preg\_split, keep splitter

**URL:** <https://forum.kirupa.com/t/php-preg-split-keep-splitter/217985>\
**Category:** programming\
**Created:** [March 3, 2007, 10:13pm UTC](https://forum.kirupa.com/t/php-preg-split-keep-splitter/217985 "2007-03-03T22:13:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![evildrummer](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/evildrummer/32/2308_2.png) [@evildrummer](https://forum.kirupa.com/u/evildrummer)\
**Post date:** [March 3, 2007, 10:13pm UTC](https://forum.kirupa.com/t/php-preg-split-keep-splitter/217985/1 "2007-03-03T22:13:50Z")

</div>

This is probably easy but google and [php.net](http://php.net) yield no help so someone here might no, is there a way of using preg\_split but keeping the splitter on the end of each array entry. EXAMPLE:

```php

$string = 'Normal preg_split. takes away. the. full stops.';
$lines = preg_split('/\.\s/', $string);
$string = implode('', $lines);
echo $string;
// outputs 'Normal preg_split takes away the full stops'

/*BUT I need to keep those because I am using preg-split
to also check for ?, ! and .'s and need to put them back in their right place. */

```
