/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] slicing a paragraph

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

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@DJsACSep 08.2006 — list($firstrow,$secondrow) = explode(".",$str,2);
Copy linkTweet thisAlerts:
@bokehSep 08.2006 — [code=php]if(false !== ($position = strpos($str, '.')))
{
$part_one = substr($str, 0, $position + 1);
$part_two = substr($str, $position + 1);
}[/code]
Copy linkTweet thisAlerts:
@raj_2006authorSep 08.2006 — 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
×

Success!

Help @raj_2006 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.27,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...