Whoops, sorry, I added up wrong. $numGuests should = 3.
I'm splitting them so I can insert them into a database, recombining and echoing them is purely for testing.
This is the only piece that is giving me problems.. but just in case here is the whole function:
the name POST is full names separated by commas eg: Jane doe,Mark Smith,John Doe
the email POST is email addresses separated by commas.
$nameArray = explode(',', $this->input->POST('name',true));
$emailArray = explode(',', $this->input->POST('email',true));
$eventId = $this->input->POST('eventid',true);
$ePid = $this->input->POST('ePid',true);
$numGuests = $this->input->POST('guests',true);
$i = 0;
while($i <= $numGuests){
$splitName = preg_split("/ /", $nameArray[$i];
$data['stuff'] = $nameArray[0].' / '.$nameArray[1].'<br/>'.$splitName[0].' + '.$splitName[1];
$additional_data = array(
'first_name' => $splitName[0],
'last_name' => $splitName[1],
'email_rvsp' => "1",
'email_message' => "1",
'email_pic' => "1",
'email_invite_other' => "0",
);
$id = $this->ion_auth->register(null, base64_decode($ePid), $emailArray[$i], $additional_data, 'EGuest');
$guestData = array('event_id' => $eventId, 'user_id' => $id);
$this->db->insert('guests', $guestData);
$i++;
}
Just in case I was confusing above, the problem I am encountering is that if I put $nameArray[$i]; into the preg_split() statement, it states that $splitName[1] does not exist and $splitName[0] is empty . However, if I put $nameArray[0]; it all works fine.
I was originally using explode(), however it gives me the same problem
Thanks for the help!