Попробуй это.Должно работать.
$criteria = '';
$facets = array();
foreach (explode(' ' , $input) as $word) {
// This word is a facet
if (strpos($word, ':')) {
list($facet_name, $facet_criteria) = explode(':', $word, 1);
$facets[$facet_name] = $facet_criteria;
// This word is a search criteria
} else {
$criteria .= $word . ' ';
}
}
Вход ($input
значение):
chevy tahoe city:seattle color:desert dune capacity:7
Выход:
$criteria: chevy tahoe dune
$facets: Array (
[city] => seattle
[color] => desert
[capacity] => 7
)