Splitting a string first by quotes then spaces

From: Date: Mon, 09 Jul 2001 22:48:06 +0000
Subject: Splitting a string first by quotes then spaces
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-57032@lists.php.net to get a copy of this message
Ok, heres one for y'all.... I have the user entering a free formed string (such as a search engine query).. and i want to parse that string into an array of string elements... If the user enters elements within double quotes, that would appear as one entity.. for each word outside of containing quotes, it would be treated as a sole entity.. For instance, the query: house shoe "mother goose" story would return an array with elements: [0] => house [1] => shoe [2] => mother goose [3] => story (note element [2] is multiple word...) I've been playing with explode($delimiter,$array) but if i use a double quote there, it will want to split anything up to the first instance into a sincle entity, then on from there... any ideas? -- Aaron

« previous php.general (#57032) next »