rendered paste body<?php//http://digitalx.org/cuesheetsyntax.phpfunction parse_cuesheet($cuesheet){ //$i=0; $j=0; $syntax_array = array ('catalog','cdtextfile','file', 'flags','index','isrc', 'performer','postgap','pregap', 'rem','songwriter','title', 'track'); //list of keywords $cue_array = file($cuesheet); #open cuesheet into array print_r($cue_array); echo "debug: opened file, " . count($cue_array) . " lines\n"; for ($i=0; $i<=count($cue_array); $i++) { echo "debug: loop level 1 (i: $i)\n"; print "$cue_array[$i]"; $parseable_line = trim(strtolower($cue_array[$i])); //lowercase'd line print "$parseable_line\n"; foreach ($syntax_array as $keyword) { echo "debug: loop level 2 (i: $i)\n"; if (strpos($parseable_line,$keyword)===0); // we have a match { if ($keyword=="track") { //we've found a track echo "track found at line $i\n"; $j++; print $j; $parsed_cue[$j][$keyword] = $cue_array[$i]; $i++; //we've grabbed the track, now increment to the next line $inner_parseable_line = trim(strtolower($cue_array[$i])); //lowercase'd line while (!strpos($cue_array[$i], "TRACK")===0) {//this inner loop grabs track info echo "debug: loop level 3 (i: $i)\n"; foreach ($syntax_array as $tkeyword) { echo "debug: loop level 4 (i: $i)\n"; if (strpos($inner_parseable_line,$tkeyword)==0) { echo "debug: track line found inside track $j, at line $i\n"; $parsed_cue[$j][$keyword] = $cue_array[$i]; $i++; } } echo "debug: loop level 3 (i: $i)\n"; } echo "debug: loop level 2 (i: $i)\n"; } } } } echo "done, with " . count($parsed_cue) . "parseable lines and " . $j . " tracks\n";echo $parsed_cuesheet;} print_r(parse_cuesheet('test.cue'));?>