从具有多个条目的表单中的变量数组之前和之后剥离空格

I have a form that inputs data using explode and splits the entry into 2 fields so from

START POINTS
_3Bug_Salad 1
devinm21 1
Misfit_Eye1 3
Mrslookingfor25 3
Kaibrosky 5
sajoma 6
BRs_Ronycezar 14
UBG_Arielle 19
SG_Bluemango22 29
DJ_Habs 10
STOP POINTS

it puts into PlayerName and points which works almost perfect the only issue is when I have a space before or 2 spaces after the names it stops the code

here is the code I am using

    $Points = explode("
", $Points);
    foreach ($Points as $v)
    {
    if ($v == "") continue;
    $v = explode (" ", $v);
    if (count($v) != 2)
    die("Incorrect values in POINTS input (check spaces!)<br>");
    if (strstr(strtolower($v[1]), 'points')) continue;
    $r = mysql_query("insert into points values ('','${v[0]}', 
    ${v[1]}, '".$_POST["tourdate"]."', '".$_POST["tourtime"]."')");
    if (!$r) die (mysql_error());
    }
    echo "Points submitted Successfully";

How would I set it to trim the names so that it can only start with a alphanumeric or _ and only have one space after the name and if not remove the whitespaces

to explain better

_3Bug_Salad 1 works
 _3Bug_Salad 1 doesnt work
_3Bug_Salad   1 doesnt work

where I need all 3 to submit _3Bug_Salad to player name and
1 to points column

$v = array_filter( explode (" ", trim($v)) , "strlen");

Try this.