Tell me how to solve the problem, I need to split the string into an array:

$s = "бла бла бла Сила+5 бла бла бла Ловкость+12 бла бла бла Шанс-2"; 

I wanted to use a separator to make a space preceded by digits:

  $a = preg_split("/\d+\s+/", $s); 

but this way I cut off the numbers I need.

  • blah blah sila +
  • blah blah blah dexterity +
  • blah blah blah Chance
  • one
    Basically, you could just add the key \ K - `$ a = preg_split (" / \ d + \ K \ s + / ", $ s) to your code;` - splash58

1 answer 1

You can use the retrospective test.

 <?php $s = "бла бла бла Сила+5 бла бла бла Ловкость+12 бла бла бла Шанс-2"; $a = preg_split("/(?<=[0-9])\s+/", $s); echo "<pre>"; print_r($a);