note 13669 added to function.explode.php

From: Date: Thu, 28 Jun 2001 09:33:55 +0000
Subject: note 13669 added to function.explode.php
Groups: php.notes 
Request: Send a blank email to php-notes+get-14711@lists.php.net to get a copy of this message
/** * NAME: explodeQuoted() * DESCRIPTION: Explode a quoted string into elements. Does not work * flawlessly because it only checks the first and last char * of every word. But this will suffice normally and is very fast. * AUTHOR: Marc Spoorendonk a.k.a. Grmbl * DATE: 2001-06-28 10:31:52 CET */ function explodeQuoted($str) { $inQuotes=false; $words=explode(" ", $str); foreach($words as $word) { if($inQuotes==true) { // add word to the last element $elements[sizeof($elements)-1].=" ".$word; if($word[strlen($word)-1]=="\"") $inQuotes=false; } else { // create a new element $elements[]=$word; if($word[0]=="\"" && $word[strlen($word)-1]!="\"") $inQuotes=true; } } return $elements; } http://www.php.net/manual/en/function.explode.php

« previous php.notes (#14711) next »