title: Format "raw" string to Java UUID in PHP
body: <p>Is there a more effective, simplified means of converting a "formatted" Java UUID - without dashes - to a Java compatible format - with dashes - in PHP, and ultimately: How would I do it?</p>
  
  <p>I have code that already performs this action, but it seems unprofessional and I feel that it could probably be done more effectively.</p>
  
  <pre><code>[... PHP code ...]
  $uuido = $json['id'];
  
  $uuidx = array();
  $uuidx[0] = substr( $uuido, 0, 8 );
  $uuidx[1] = substr( $uuido, 8, 4 );
  $uuidx[2] = substr( $uuido, 12, 4);
  $uuidx[3] = substr( $uuido, 16, 4);
  $uuidx[4] = substr( $uuido, 20, 12);
  
  $uuid = implode( "-", $uuidx );
  [... PHP code ...]
  
  Input:  f9e113324bd449809b98b0925eac3141
  Output: f9e11332-4bd4-4980-9b98-b0925eac3141
  </code></pre>
  
  <p>The data from <code>$json['id']</code> is called from the following <a href="https://api.mojang.com/users/profiles/minecraft/LeoV117" rel="nofollow">Mojang Profile API</a> using the <code>file_get_contents( $url )</code> function combined with a <code>json_decode( $file )</code>, which could alternatively be done through cURL - but since it would eventually be requesting anything up to 2048 profiles at once, I figured it would become slow.</p>
  
  <p>I do have my code in use, and public, through the following <a href="https://www.projectrogue.co.uk/api/minecraft/query/151.80.170.47/27015" rel="nofollow">ProjectRogue Server Ping API</a>, which usually contains a list of online players.</p>
  
  <p><strong>Note:</strong> There are several questions related to this, but none apply to PHP as far as I am aware. I have looked.</p>
  
  <p>I mention Java UUID as the parsed output should effectively translate to a Player UUID for use in a Java-Based plugin for Spigot or Craftbukkit after 1.7.X.</p>