Split a full name using PHP list or explode function

I am trying to split a name that I pull from a webpage using simple HTML DOM and the list and explode functions aren't doing the trick. All I want to do is take a name {firstname middle(optional) lastname} and split them. The middle name only shows up on some names and it would be a bonus if I could handle that.

Here's the code:

    <?php

    $data = new simple_html_dom();  
    $data->load_file("http://www.ratemyprofessors.com/ShowRatings.jsp?tid=861228");
    $profName= $data->find("//*[@id=profName]", 0);
    $profName = strip_tags($profName);
    echo "Full Name: " . $profName = trim($profName);
    list($first, $last) = explode(' ', "$profName ");
    echo "first name: " .  $first;
    echo "last name: " . $last;
?>

My output reads:

Full Name: Jennifer Aaker
firstname: Jennifer Aaker
lastname: 

Answers


try with:

list($first, $last) = explode("&nbsp;", $profName);

Need Your Help

.LESS together with Razor

css asp.net-mvc razor sass less

Is it possible to use Razor View Engine (ASP.NET MVC) together with .LESS (similar to SASS - http://lesscss.org/ for .NET), since they're both using "@blah"?

SQLite on Azure website

sqlite azure sqlite3

I've been trying to get SQLite to work on an Azure website. I have deployed everything successfully but I need to point it to a file name for the database. I have looked at creating Blob storage bu...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.