字符串的最后一个字 - 爆炸()?

So I'm trying to get the last word from a string...

$pieces = explode(" ", $row["post_content"]);
print_r($pieces);
$customerEmail = array_pop($pieces);
echo "Email: " . $customerEmail."<br><br>";

$row["post_content"] = I wish I could be the icing on the cake..whipped snapbac50@gmail

Running the code gets me:

Array ( [0] => I [1] => wish [2] => I [3] => could [4] => be [5] => the [6] => icing [7] => on [8] => the [9] => cake..whipped snapbac50@gmail.com ) Email: cake..whipped snapbac50@gmail.com

I want the end of the array to echo just the email. Why does it include cake...whipped before the email if I array_pop()? I just want the email.

Because the string contains whitespace characters other than spaces, you will have to use a different function: preg_split('/\s+/', $row['post_content']);

This will split the string using the pcre regular expression for one or more whitespace characters.