title: PHP returning an element from an array
body: <p>So I have some code that returns all the time in an array like this <strong>Open hours today: 9:00- 9:45, 9:55 - 10:20, 10:30 - 11:00</strong> . If we used $formatted_ranges[array_key_first($formatted_ranges)] instead of join, it would return a single element as like this, &quot;Open hours today: 9:00 - 9:45&quot;. However we need to return like this,</p>
  <p>Open hours today: 9:00 - 11:00.</p>
  <pre><code>$start = DateTime::createFromFormat( 'H:i', $range['from'] );
  $end = DateTime::createFromFormat( 'H:i', $range['to'] );
  
  $formatted_ranges = array_map( function( $range ) {
              return $this-&gt;format_time( $range['from'] ).' - '.$this-&gt;format_time($range['to'] );
  }, $ranges );
  
  return sprintf(
    __( 'Open hours today:', 'example' ) . ' &lt;span&gt;%s&lt;/span&gt;',
              join( ', ', $formatted_ranges )
          );
  
  </code></pre>