note 104059 deleted from control-structures.foreach by danbrown

From: Date: Fri, 20 May 2011 14:29:05 +0000
Subject: note 104059 deleted from control-structures.foreach by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-179910@lists.php.net to get a copy of this message
Note Submitter: billardmchl at aol dot com ---- This function find well the words, add well adds a () around short words, but the array at the end of th function is the same as at the beginning. function isole_mots($chaine) { $chaine = "le petit chat est fou"; $mots = preg_split('/[!,-.;?:()[ ]/', $chaine, -1, PREG_SPLIT_NO_EMPTY); foreach ($mots as $mot) { if (strlen($mot) <= 3) $mot = "(".$mot.")"; print " inside foreach $mot <br>"; } print "after foreach array mots"; print_r($mots); die(); return $mots; } inside foreach (le) inside foreach petit inside foreach chat inside foreach (est) inside foreach (fou) after foreach array motsArray ( [0] => le [1] => petit [2] => chat [3] => est [4] => fou )

« previous php.notes (#179910) next »