07-15-2007, 06:47 AM
[eluser]Phil Sturgeon[/eluser]
They seem to break when only word is sent in.
My reccomendation to the team is to use my str_replace based functions instead. Its the most simply of changes but seems to work where the preg_replace ones dont.
Meanwhile if anyone else has this problem, just throw this into a custom /application/helpers/inflector_helper.php
They seem to break when only word is sent in.
Code:
echo humanize('foo'); // outputs nothing
echo humanize('foo_bar'); // outputs Foo Bar
My reccomendation to the team is to use my str_replace based functions instead. Its the most simply of changes but seems to work where the preg_replace ones dont.
Code:
// --------------------------------------------------------------------
/**
* Underscore
*
* Takes multiple words separated by spaces and underscores them
*
* @access public
* @param string
* @return str
*/
function underscore($str)
{
return str_replace('_', ' ', strtolower(trim($str)));
}
// --------------------------------------------------------------------
/**
* Humanize
*
* Takes multiple words separated by underscores and changes them to spaces
*
* @access public
* @param string
* @return str
*/
function humanize($str)
{
return ucwords(str_replace('_', ' ', strtolower(trim($str))));
}
Meanwhile if anyone else has this problem, just throw this into a custom /application/helpers/inflector_helper.php