PHP reorder array with starting index -


I have an array of weeks that I want to order again by giving the starting day.

$ days_order = array ("Mon", "Mars", "Mercury", "Guru", "Venus", "Saturn", "Sun"); Echo '& lt; Pre & gt; '; Print_r ($ days_order); Echo & lt; / Pre & gt; ';

output

  array ([0] => som [1] => Mars [2] = & gt; Mercury [3 ] = & Gt; Master [4] = & gt; Venus [5] => Saturn [6] => Sun)  

Question: How to re-order array when set to start day?

Note: Index values ​​are important.

Example:

If I set day start "Mercury" , then array it Will produce:

  array ([0] = & gt; Mercury [1] => Thurs [2] => Venus [3] => Saturn [4] = & Gt; Sun [5] = & gt; Mon [6] = & gt; Mars)  

There is no array of pre-defined dates, just loop through date.

  $ start_date = 'Mercury'; ($ I = 0; $ i & lt; 7; $ i ++) $ arr [$ i] = Date ('D', Stromathem ("Next $ start_date + $ i day"));  

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -