I've written what I thought was a very simple use of the php explode()
function to split a name into forename and surname:
// split name into first and last
$split = explode(' ', $fullname, 2);
$first = $split[0];
$last = $split[1];
However, this is throwing up a php error with the message "Undefined offset: 1"
. The function still seems to work, but I'd like to clear up whatever is causing the error. I've checked the php manual but their examples use the same syntax as above.
I think I understand what an undefined offset is, but I can't see why my code is generating the error!