Exploding a string into equal portions
问题 $str = "Hello fri3nd, you're looking good today! What a Great day this is! How fancy and cool!"; $pieces = explode(" ",$str, 3); print_r($pieces); so this gives me $pieces[0] = 'Hello', $pieces[1] = 'fri3nd' ... and the rest of the string is all shoved into $pieces[3]`. How can I explode into every 3 or 4 words? 回答1: Maybe:? <?php $str = "Hello fri3nd, you're looking good today! What a Great day this is! How fancy and cool!"; $array = array_map(create_function('$a', 'return implode(" ", $a);'