Welcome Guest, Not a member yet? Register   Sign In
where can i put my own function
#1

[eluser]syntaxerror[/eluser]
hi,
can anyone please help me.
i have my own function that makes an array to lower case (strtolower)
because php has no built in function to convert array to lower case
i make my own function.
my question is where should i put this function in code igniter?
model?view? or controller?

BTW my script is
Code:
function arraytolower($array,$round = 0){
    foreach($array as $key => $value){
        if(is_array($value)) $array[strtolower($key)] =  $this->arraytolower($value,$round+1);
        else $array[strtolower($key)] = strtolower($value);
        }
        return $array;
    }

thanks
#2

[eluser]OES[/eluser]
Create a new library for this type of thing.

Ie Common.

Then within yout controller load it like any other.

$this->load->library('common');

Then to use it ie.

$this->common->arraytolower($array,$round)

Hope this helps.
#3

[eluser]Sarfaraz Momin[/eluser]
Well if there is just a single function related to it I would go about creating a helper.

Code:
//load helper
$this->load->helper(‘common’);

//use function
arraytolower($array,$round)

Have a good day !!!
#4

[eluser]syntaxerror[/eluser]
i add it in the array_helper,
and load it.
and use the function,
well, it seems working.

thanks




Theme © iAndrew 2016 - Forum software by © MyBB