Jump to content

How to split every two words in a sentence?


etrader

Recommended Posts

In a string containing a simple sentence as

$str="word1 word2 word3 word4 word5"

I want to split every two words. Actually, performing explode() for every other 'space' (not all of them). To create

$array[0]="word1 word2";
$array[1]="word3 word4";
$array[2]="word5";

 

Any idea?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.