Archive for the Category: PHP

Split a name into First name and Last name using PHP

/** split a name into the first name and last name * @param input The name eg ‘John Doe’ * @return Array containing firstname and lastname eg array(‘firstname’=>’John’, ‘lastname’=>’Doe’); */ function splitname($input) { $output = array(“firstname”=>””, “lastname”=>””); $space = strpos($input, ” “); if ($space !== false) { $output[‘firstname’] = substr($input, 0, $space); $output[‘lastname’] = substr($input, […]

1 Comment

Convert a url data in to Name Value Pairs array PHP

Convert a url data in to Name Value Pairs array. /** Convert a url data in to Name Value Pairs array * @param url The url and the data string * @return array of named value pairs */ function urlToNvp($url) { $output = array(); $questionmark = strpos($url, ‘?’); if ($questionmark !== false) { $url = […]

Leave a comment

Sound Buttons

Sound Buttons are a technique used to teach children to read. This function generates the sound buttons for a given word, uing the Jolly Phonics system. This approach breaks each word into the groups of letter sounds, of which there are 42 letter sounds. /** * Generates phonics for a given word. * This function […]

Also posted in Natural Language Processing 3 Comments

Convert a date and time to UTC

/** Converts a date and time to UTC * /param date The date in the format dd/mm/yyyy * /param time The time in the format HH/mm/ss * /return utc */¬† ¬† function utc($inputDate, $inputTime) { $pieces = explode(“/”, $inputDate); $dateus = $pieces[2].”-“.$pieces[1].”-“.$pieces[0]; $stringtime = “$dateus $inputTime”; return strtotime($stringtime); }

Leave a comment