Explode with multiple selection

I need to split a string that contains a last name and first name. Right now, this code works if I only select one name from a list. But, when I select multiple names, it doesn’t work. I’m using this to populate an SQL IN statement so it needs to be (‘xyz’,‘abc’, etc.)

$name ="";
foreach ($_SESSION[name] as $n){
$name .= “’” . $n . “’,”;
}
$name = substr($name,0,-1);
$name = “(” .$name . “)”;
$_SESSION[name] = $name;

$name = explode (" ", $_SESSION[name]);
$lname = $name[0] . “’)”;
$fname = “(’” .$name[1];

Huh?

It looks like it is an array, that you make a string, to make it an array?

Sponsor our Newsletter | Privacy Policy | Terms of Service