Skip to content

Instantly share code, notes, and snippets.

@Relequestual
Created March 28, 2012 22:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Relequestual/2230990 to your computer and use it in GitHub Desktop.
Save Relequestual/2230990 to your computer and use it in GitHub Desktop.
Split a string which starts with lowercase then uses camel case from first capital letter.
<?php
/*
/ Created while using the Last.FM API.
/ The Last.FM API is split into sections. Artists, Album, Track etc.
/ The method names are for example "artists.getTopTracks". If I'm using magic method __call
/ and calling artistsGetTopTracks, I can then split the call down into the section and method with the following regex
/ which can then be used to construct API call URL
*/
preg_match_all('/^[a-z]*|[A-Z]\w*/', $candidate, $results);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment