John Davidson

php - Extract all numbers and text separetely

0 comments
Message:


I have a text like this:


81. Text1

82. Text2
82.1. Some text3
82.2. Some long text goes there in two or more lines... Some more text goes here...

83. Text4

84. Text5

It has some random spacing between the lines. I'm trying to extract every single option separately. So for example my output for 82.2. should be like this: "82.2." and "Some long text goes there in two or more lines... Some more text goes here...".


I've already tried to do this like that:


$exp = explode(". ", $text);
foreach($exp as $newline) {

echo explode(". ", $newline)[0];
}

But probably that's not the best idea, because sometimes there's an ". " in the end of sentence.



My Answer:
Number: 82.2.
Text: Some long text goes there in two or more lines... Some more text goes here...

Rate this post

4 of 5 based on 5552 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us