The logic I need is pretty straight forward, but I am having a hard time replicating it using PHP functions. I will try to break it down to it's simplest form:
I have a field that has several lines of text. Chords and Song Lyrics.
The "Chord" lines begin with an asterisk "*" (first character) and end with the line break. These are the strings I want to parse. Lines with NO asterisk at the beginning are ignored.
Based on 3 arrays of NOTES, I want SUBSTITUTE the text (based on exact text character patterns - just NOTES not the chord type) of the lines in my field that start with an asterisk "*".
original_chord_array = A, A#, B, C, C#, D, D#, E, F, F#, G, G#
transpose_up_array = A#, B, C, C#, D, D#, E, F, F#, G, G#, A
transpose_down_array = G#, A, A#, B, C, C#, D, D#, E, F, F#, G
It is important that it only effects EXACT strings. Notes will always be capitalized and chord types will be lower case. Maybe we can use that characteristic to better identify what to change. Here are some examples of chords:
When I transpose UP these chords, just the NOTE should change:
When I transpose DOWN these chords, just the NOTE should change:
Hopefully this break down is clear and someone will bail me out ;-)
OK, should be straightforward. You need to set up a multidimensional array - or you can stick with your 3 arrays. However, it may be useful to place all the sharps first. This means that your replacement function will search for these first. If a match is made - you replace and then move on to the next part of the string. If you replaced with the 'normal' note, you'd end up incorrectly replacing a sharp note.