Guest User

Untitled

a guest
Oct 18th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. <?php
  2. //original string from textarea
  3. $string = "1. Vojta\n 2. Zdenda \n 3.Kamarádovi rodiče";
  4. $lines = explode("\n", $string);
  5. print_r($lines);
  6. foreach ($lines as $line) {
  7. $matches = [];
  8. preg_match('/^([1-9\ ]*)[\.\ ]*(.*)/', $line, $matches);
  9. //if no matches found in arrray will be 0 rows
  10. if(count($matches) > 0) {
  11. echo trim($matches[2]) . "\n";
  12. }
  13. }
  14. ?>
Add Comment
Please, Sign In to add comment