没有最后一项在php中的echo数组

Does anyone know how to not echo the last item in an array? I'm really new to php.

Here is the part I'm having trouble with:

...

return($keywords);

}

$words = (mixer(strtolower($keywordlist)));
$query =  implode(',', $words);
echo('Search query: ' . $query . PHP_EOL);
$query = rawurlencode($query);
echo('Encoded: ' . $query . PHP_EOL);
***trying to remove last item in array from showing here***
echo('Without Last: ' . $query . PHP_EOL);

If I put array_shift($query); or array_pop($query); or array_shift($array,1,-1)); were the stars are I get this error:

Parse error: syntax error, unexpected T_ECHO in /home/content/14/7557914/html/test2.php on line 102 
line 102 = echo('Without Last: ' . $query . PHP_EOL);  

What am I doing wrong?

Because you don't have an array. You already imploded it, so it is a string. You'd need to array_pop($words), then implode(',',$words).... not $query.