I have this code:
$data = explode("\n", $_POST['multiplekeywords']
);
When I take $data and insert it into a database like:
foreach ($data as $keyword) {
if (trim($keyword) != '') {
$sql = "INSERT INTO listing (campaign_name,adgroup_nam
e,keyword_
name,domai
n,max_bid,
phrase,exa
ct) VALUES ('$campaign','$adgroup','$
keyword','
$domain','
$bid','$ph
rase','$ex
act')";
$result = mysql_query($sql, $connect) or die(mysql_error());
echo mysql_error();
echo "New Listing Added To Database <br />";
}
}
}
It seems to ad an extra space at the end of the keyword value, at least for all the values besides the last, if i have 10 values values in that array, the first nine will have an extra space attached. How could I remove this space?
Start Free Trial