CodeIgniter User Guide Version 2.2.6 |
Table of Contents Page |
CodeIgniter Home › User Guide Home › Inflector Helper |
The Inflector Helper file contains functions that permits you to change words to plural, singular, camel case, etc.
This helper is loaded using the following code:
$this->load->helper('inflector');
The following functions are available:
Changes a plural word to singular. Example:
$word = "dogs";
echo singular($word); // Returns "dog"
Changes a singular word to plural. Example:
$word = "dog";
echo plural($word); // Returns "dogs"
To force a word to end with "es" use a second "true" argument.
$word = "pass";
echo plural($word, TRUE); // Returns "passes"
Changes a string of words separated by spaces or underscores to camel case. Example:
$word = "my_dog_spot";
echo camelize($word); // Returns "myDogSpot"
Takes multiple words separated by spaces and underscores them. Example:
$word = "my dog spot";
echo underscore($word); // Returns "my_dog_spot"
Takes multiple words separated by underscores and adds spaces between them. Each word is capitalized. Example:
$word = "my_dog_spot";
echo humanize($word); // Returns "My Dog Spot"
Previous Topic: HTML Helper · Top of Page · User Guide Home · Next Topic: Number Helper
CodeIgniter · Copyright © 2006 - 2014 · EllisLab, Inc. · Copyright © 2014 - 2015 · British Columbia Institute of Technology