Connecting Tech Pros Worldwide Help | Site Map

preg_match quastion

 
LinkBack Thread Tools Search this Thread
  #1  
Old March 6th, 2006, 01:45 AM
kirill_uk@hotmail.com
Guest
 
Posts: n/a
Default preg_match quastion

Hi All, wondering if someone could help me with this.
I have a variable $var="blh blh blah bldd erter etert";
i need to get first three words from it so basically i have to
,somehow, count first three spaces and get "blh blh blah" to a new var.
Any idea?
Thank you all!


  #2  
Old March 6th, 2006, 09:55 AM
d
Guest
 
Posts: n/a
Default Re: preg_match quastion

<kirill_uk@hotmail.com> wrote in message
news:1141612600.759943.298690@e56g2000cwe.googlegr oups.com...[color=blue]
> Hi All, wondering if someone could help me with this.
> I have a variable $var="blh blh blah bldd erter etert";
> i need to get first three words from it so basically i have to
> ,somehow, count first three spaces and get "blh blh blah" to a new var.
> Any idea?
> Thank you all![/color]

$first_three=join(" ", array_slice(explode(" ", $var), 0, 3));

if you want to do it without preg_match :)


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.