custom functions

i want to convert this code in some function and want to access it through out application

$yearNow = date("Y");

$yearFrom = $yearNow - 100;

$yearTo = $yearNow - 18;

$arrYears = array();

	 foreach (range($yearFrom, $yearTo) as $number) {


	 $arrYears[$number] = $number; 


	 }

$arrYears = array_reverse($arrYears, true);

how should i do it?

Create some custom function.

See this wiki for inspiration.

Thanks again…

Glad it helped you. (P.S: welcome to the forum)

Could make a helper class and have Yii auto import.




class Helper {

    static function myFunction() {

        //...

    }

}



Then call it like




Helper::myFunction();



This is a solution similar to what does CHtml, and is what I usually do.

This wiki is also of Qiang, and allows to create shorter function.

The are absolutely equivalent, is just a question of taste.