note 102928 rejected from function.preg-split by danbrown

From: Date: Tue, 15 Mar 2011 13:41:31 +0000
Subject: note 102928 rejected from function.preg-split by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-177886@lists.php.net to get a copy of this message
Note Submitter: tkama at bk dot ru ---- This mistake look like a paradox, but that's what I see: Example 1: $str = 'hypertext language programming'; $chars = preg_split('/ /', $str, -1, PREG_SPLIT_OFFSET_CAPTURE); foreach($chars as $k=>$v){ $chars2[] = $chars[$k][0]; } print_r($chars2); Example 2: $str = 'hypertext language programming'; $chars = preg_split('/ /', $str); print_r($chars); First example works faster then second. Why so?

« previous php.notes (#177886) next »