$str = $query; explode(' ', $str); array($str); foreach ($str as $do) { echo "$do"; }