如何将包含姓名和有时中间名的字符串转换为具有此格式的数组?将字符串转换为特定格式的数组
customFunction('Chris Morris');
// array('firstname' => 'Chris', 'lastname' => 'Morris')
customFunction('Chris D. Morris');
// array('firstname' => 'Chris D.', 'lastname' => 'Morris')
customFunction('Chris');
// array('firstname' => 'Chris', 'lastname' => '')
将字符串传递给函数时,我得到数组进行字符串转换。 – MagentoMan 2014-09-03 15:32:27
只是修正了它...虽然我看到两个其他解决方案更短。我会用其中之一。 – 2014-09-03 15:35:22