Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Using <a href="http://php.net/manual/en/function.strftime.php" rel="noreferrer"><code>strftime()</code></a> in combination with <a href="http://php.net/manual/en/function.setlocale.php" rel="noreferrer"><code>setlocale()</code></a> is an option.</p> <p>However you should be aware that on threaded php installs, <code>setlocale()</code> can behave unexpected, since locale information is maintained per process, not per thread. Therefor it is important to call <code>setlocale()</code> every time before each call to <code>strftime()</code> to guarantee it uses the correct locale.</p> <p>Also, for Windows systems, you need to use somewhat unusual strings for the <code>$locale</code> parameter for <code>setlocale()</code>.</p> <p>See the docs for more information on both of these issues.</p> <p>Something like this should work:</p> <pre><code>// define the locales for setlocale() for which we need the daynames $locales = array( 'en_EN', 'de_DE', 'nl_NL' // etc... ); // be aware that setlocale() needs different values on Windows machines // see the docs on setlocale() for more information $locales = array( 'english', 'german', 'dutch' // etc... ); // let's remember the current local setting $oldLocale = setlocale( LC_TIME, '0' ); // initialize out result array $localizedWeekdays = array(); // loop each locale foreach( $locales as $locale ) { // create sub result array for this locale $localizedWeekdays[ $locale ] = array(); // 7 days in a week for( $i = 0; $i &lt; 7; $i++ ) { // set the locale on each iteration again setlocale( LC_TIME, $locale ); // combine strftime() with the nifty strtotime() $localizedWeekdays[ $locale ][] = strftime( '%A', strtotime( 'next Monday +' . $i . ' days' ) ); // reset the locale for other threads, as a courtesy setlocale( LC_TIME, $oldLocale ); } } // there is your result in a multi-dimensional array var_dump( $localizedWeekdays ); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload