preg_split

Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Split string by a regular expression
<?php preg_split(    string $pattern,    string $subject,    int $limit = -1,    int $flags = 0): array|false
<?php             && is_numeric((string) $svg['height'])) {

            return [(float) $svg['width'], (float) $svg['height']];

        } elseif ($svg['viewBox']) {

            $viewBox = preg_split('/[\s,]+/', $svg['viewBox'] ?: '');



            return [$viewBox[2], $viewBox[3]];

        }
<?php     protected function convertToSets($html)

    {

        $arr = preg_split('/(<set>index-\d+<\/set>)/', $html, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);



        return collect($arr)->map(function ($html) {

            if (preg_match('/^<set>index-(\d+)<\/set>/', $html, $matches)) {
<?php     public function wordCount($value)

    {


        $words = empty($string = trim($value)) ? [] : preg_split('~[^\p{L}\p{N}\']+~u', $value);



        return count($words);

    }
<?php                         continue;

                    }



                    $words = preg_split("#\s#i", $property);

                    $strength = (! isset($this->property_weights[$name])) ? 1 : $this->property_weights[$name];
<?php         if ($this->query_mode === self::QUERY_WORDS) {

            $parts['chunks'] = preg_split("/\s+/i", $query);



            if ($this->use_alternates) {

                $parts['chunks'] = array_merge($parts['chunks'], $this->getAlternateWords($parts['chunks']));
<?php         } elseif ($this->query_mode === self::QUERY_BOOLEAN) {

            $words = preg_split("/\s+/i", $query);



            if ($this->use_alternates) {

                $parts['chunks'] = array_merge($parts['chunks'], $this->getAlternateWords($words));
<?php         if (Str::contains($var, [' or ', ' ?? ', ' ?: '])) {

            $isCoalesce = true;

            $vars = preg_split('/(\s+or\s+|\s+\?\?\s+|\s+\?\:\s+)/ms', $var, null, PREG_SPLIT_NO_EMPTY);

        } else {

            $isCoalesce = false;

            $vars = [$var];
<?php         [$first, $rest] = preg_split("/(\:|\.)/", $key, 2);



        if (! Arr::has($context, $first)) {
<?php         $content = null;



        if (Pattern::startsWith($str, '---')) {

            $split = preg_split("/\n---/", $str, 2, PREG_SPLIT_NO_EMPTY);

            $str = $split[0];

            if (empty($content = ltrim(array_get($split, 1, '')))) {

                $content = null;