note 104060 added to control-structures.foreach

From: Date: Fri, 20 May 2011 08:20:17 +0000
Subject: note 104060 added to control-structures.foreach
Groups: php.notes 
Request: Send a blank email to php-notes+get-179897@lists.php.net to get a copy of this message
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 ) ---- Server IP: 195.221.21.36 Probable Submitter: 88.219.134.169 ---- Manual Page -- http://www.php.net/manual/en/control-structures.foreach.php Edit -- https://master.php.net/note/edit/104060 Del: integrated -- https://master.php.net/note/delete/104060/integrated Del: useless -- https://master.php.net/note/delete/104060/useless Del: bad code -- https://master.php.net/note/delete/104060/bad+code Del: spam -- https://master.php.net/note/delete/104060/spam Del: non-english -- https://master.php.net/note/delete/104060/non-english Del: in docs -- https://master.php.net/note/delete/104060/in+docs Del: other reasons-- https://master.php.net/note/delete/104060 Reject -- https://master.php.net/note/reject/104060 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#179897) next »