Nyttige PHP funktioner

      5 function eng2dan($ls,$string)
      6 {
      7         $da_mon_long=array("Januar","Februar","Marts","April","Maj","Juni","Juli","August","September","Oktober","November","December");
      8         $da_mon_short=array("Jan","Feb","Mar","Apr","Maj","Jun","Jul","Aug","Sep","Okt","Nov","Dec");
      9
     10         $da_day_long=array("Mandag","Tirsdag","Onsdag","Torsdag","Fredag","Lørdag","Søndag");
     11         $da_day_short=array("Man","Tir","Ons","Tor","Fre","Lør","Søn");
     12
     13         for ($i=0; $i<7; $i++) { $eng_days[]=date("D",(24*60*60)*(4+$i)); }
     14         for ($i=0; $i<12; $i++) { $eng_month[]=date("M",(24*60*60*31)*($i)); }
     15
     16         if ($ls == "long")
     17                 { return str_replace($eng_days,$da_day_long,str_replace($eng_month,$da_mon_long,$string)); }
     18         else
     19                 { return str_replace($eng_days,$da_day_short,str_replace($eng_month,$da_mon_short,$string)); }
     20 }
Dette indlæg blev udgivet i Knowledge Base, Old Base, Programmering. Bogmærk permalinket.

Skriv et svar