Use at own risk. Programs haven't been thoroughly tested.
function: extract_guitarchords
Regex function to extract guitar chords from a string Very usefull for parsing guitar tablature. Returns an array with chords.
Info
@author Kevin van Zonneveld
@version 0.9
@link http://kevin.vanzonneveld.net
@param (string) $data The haystack to search in
@version 0.9
@link http://kevin.vanzonneveld.net
@param (string) $data The haystack to search in
Example
Source Code
download source<?php function extract_guitarchords($data){ $pattOneChord = '([A-G](#|b){0,1})([#\(\),-12345679Mabdgijmnorsu]){0,8}'; $patt = '(('.$pattOneChord.')(\/'.$pattOneChord.'){0,1})\s'; $no_chords = array("en","and","end","found","god","find","dan","as"); preg_match_all('/'.$patt.'/s',$data." ",$matc); $chords = array(); foreach($matc[1] as $chord){ $tmpchord=trim(str_replace(array(",",".","*"),"",$chord)); $lower_tmpchord=strtolower($tmpchord); if(in_array($lower_tmpchord,$no_chords)) continue; $chords[] = $tmpchord; } return $chords; } ?>
No comments. Be the first!