memuz
(Mh)
1
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?
zaccaria
(Matteo Falsitta)
2
Create some custom function.
See this wiki for inspiration.
zaccaria
(Matteo Falsitta)
4
Glad it helped you. (P.S: welcome to the forum)
alex-w
(Pr0j3ct A1ex)
5
Could make a helper class and have Yii auto import.
class Helper {
static function myFunction() {
//...
}
}
Then call it like
Helper::myFunction();
zaccaria
(Matteo Falsitta)
6
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.