Forum Moderators: coopster
now I have the POST data of this:
$_POST['names']
I want to take all those names (seperately, they'll be seperated by a comma) and store them in a mysql database. How would I go about doing this? I am just not sure about parsing....I can do the database part, but I just can't parse the string to get the names.
--Nick
<?php
if (isset($_POST['names']))
{
$names = array(); // array to store each name
if (is_int(strpos(',', $_POST['names'])))
{
$names = explode(',', $_POST['names']); // Multiple names
} else {
$names[] = $_POST['names']; // Just one name
}
}
?>
That will see if $_POST['names'] exists, and if it contains a comma. If it does then it splits it into an array of names which you can then use to insert into your database.