Click to See Complete Forum and Search --> : [RESOLVED] slicing a paragraph


raj_2006
09-08-2006, 08:08 AM
Hi all

I have a small text and I want to slice up till the full stop.Something like this.

$str="Hello John How are you.I am fine.I have not seen you so many days.";

I have 2 rows.In first row it will display upto first (.) and left of the string will be displayed in the 2nd row.

So the o/p will be

1st row:

Hello John How are you.

2nd row:
I am fine.I have not seen you so many days.

Thats it.I think it may be done through substr function but really I dont have any idea about how to check the 1st full stope

I was using like this before

$str= substr($str,0,100);

Please suggest me an idea.

Thanks in advance for your co-operation......Raj

DJsAC
09-08-2006, 09:59 AM
list($firstrow,$secondrow) = explode(".",$str,2);

bokeh
09-08-2006, 10:04 AM
if(false !== ($position = strpos($str, '.')))
{
$part_one = substr($str, 0, $position + 1);
$part_two = substr($str, $position + 1);
}

raj_2006
09-08-2006, 01:52 PM
Hi

Its solved.I have use this method:

if(false !== ($position = strpos($str, '.')))
{
$part_one = substr($str, 0, $position + 1);
$part_two = substr($str, $position + 1);
}

Also thanks for another solution.

raj