User:Bookofjude/Verse conversion

([0-9]+) @";

// regexp 2 $verse_pattern = "@([0-9]+) @";

// if verbose, note that the corrected text can be found at the end of the likely long information ($verbose) ? print("Verbose output enabled. Scroll to the end of this output for the corrected text. "): print("");

// begin while look while (!feof($handle)): // get line from $handle $buffer = fgets($handle, 1024); // check for chapter match if (preg_match($chapter_pattern, $buffer, $chapter_match)): // ->chapter match, set chapter to $1 "([0-9]+)" $chapter = $chapter_match[1]; // if verbose, detail output ($verbose) ? print("Found chapter: " . $chapter . " "): print(""); // not a chapter match else: // check for verse if (preg_match($verse_pattern, $buffer, $verse_match)): // set verse for verbose $verse = $verse_match[1]; // if verbose, detailed output ($verbose) ? print("Found verse: " . $verse . ". Applying fix. (". $chapter. ":" . $verse. ") "): print(""); // make the new verse with the current chapter $verse_new = ""; // s/$verse_pattern/$verse_new $buffer = preg_replace($verse_pattern, $verse_new, $buffer); else: // if verbose, detailed output ($verbose) ? print("Not a verse. Skipping... "): print(""); endif; endif; // append buffer to data $data .= $buffer; endwhile; // if verbose, detailed output ($verbose) ? print("End of file. Display corrected text: "): print("");

// output data echo " ". $data. " "; ?>