The Bible class provides a simple way of loading and printing Bible verses. Here is some code that demonstrates how to use the object:
<?
// This loads the Bible.class and makes it available
require_once('Bible.class');
// This creates a bible object with the King James Version loaded
$bible = new Bible('kjv');
// This returns the selected verses in a blockquote tag ready for display
$page->content .= $bible->parseVerse('Psalms 23');
// This changes the bible translation to the New Revised Standard Version
// This translation may not be available
$bible->setTranslation('nrsv');
// This returns the selected verses in a blockquote tag ready for display
$page->content .= $bible->parseVerse('Psalms 23');
// This demonstrates what happens when you try to load a translation you
// don't have installed
$bible->setTranslation('xyz');
// This returns the selected verses in a blockquote tag ready for display
$page->content .= $bible->parseVerse('Psalms 23');
// Because of the site (approx 5MB) of the bible XML file, you will want
// to free the object as soon as possible
unset($bible);
?>
Here is how that code looks when it is run:
1The LORD is my shepherd; I shall not want. 2He maketh me to lie down in green pastures: he leadeth me beside the still waters. 3He restoreth my soul: he leadeth me in the paths of righteousness for his name's sake. 4Yea, though I walk through the valley of the shadow of death, I will fear no evil: for thou art with me; thy rod and thy staff they comfort me. 5Thou preparest a table before me in the presence of mine enemies: thou anointest my head with oil; my cup runneth over. 6Surely goodness and mercy shall follow me all the days of my life: and I will dwell in the house of the LORD for ever.
Psalms 23 (KJV)
1A Psalm of David. The LORD is my shepherd, I shall not want. 2He makes me lie down in green pastures; he leads me beside still waters; 3he restores my soul. He leads me in right paths for his name's sake. 4Even though I walk through the darkest valley, I fear no evil; for you are with me; your rod and your staff--they comfort me. 5You prepare a table before me in the presence of my enemies; you anoint my head with oil; my cup overflows. 6Surely goodness and mercy shall follow me all the days of my life, and I shall dwell in the house of the LORD my whole life long.
Psalms 23 (NRSV)
Bible version XYZ unavailable
Here is the Bible object source code. It may run out to the right a bit.
<?
/*
##################################################
#
# Filename..........: $RCSfile: Bible.class,v $
# Original Author...: Anthony L. Awtrey
# Version...........: $Revision: 0.1 $
# Last Modified By..: $Author: aawtrey $
# Last Modified.....: $Date: 2006/09/21 09:34:00 $
#
# Copyright 2006 Anthony Awtrey
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
*/
/*
* This class provides the methods to load and query translations of the
* Bible stored in XML.
*/
class Bible {
var $error;
var $translation;
var $bible;
var $verse = array( );
var $books = array(
'genesis' => 'Genesis',
'gen' => 'Genesis',
'g' => 'Genesis',
'ex' => 'Exodus',
'exodus' => 'Exodus',
'leviticus' => 'Leviticus',
'lev' => 'Leviticus',
'numbers' => 'Numbers',
'num' => 'Numbers',
'n' => 'Numbers',
'deuteronomy' => 'Deuteronomy',
'deut' => 'Deuteronomy',
'd' => 'Deuteronomy',
'joshua' => 'Joshua',
'josh' => 'Joshua',
'judges' => 'Judges',
'jdgs' => 'Judges',
'ruth' => 'Ruth',
'1 sam' => 'I Samuel',
'1sam' => 'I Samuel',
'i samuel' => 'I Samuel',
'isamuel' => 'I Samuel',
'1 samuel' => 'I Samuel',
'1samuel' => 'I Samuel',
'ii samuel' => 'II Samuel',
'iisamuel' => 'II Samuel',
'2 sam' => 'II Samuel',
'2sam' => 'II Samuel',
'2 samuel' => 'II Samuel',
'2samuel' => 'II Samuel',
'i kings' => 'I Kings',
'ikings' => 'I Kings',
'1 kings' => 'I Kings',
'1kings' => 'I Kings',
'1 kgs' => 'I Kings',
'1kgs' => 'I Kings',
'ii kings' => 'II Kings',
'iikings' => 'II Kings',
'2 kings' => 'II Kings',
'2kings' => 'II Kings',
'2 kgs' => 'II Kings',
'2kgs' => 'II Kings',
'i chronicles' => 'I Chronicles',
'ichronicles' => 'I Chronicles',
'1 chronicles' => 'I Chronicles',
'1chronicles' => 'I Chronicles',
'ii chronicles' => 'II Chronicles',
'iichronicles' => 'II Chronicles',
'2 chronicles' => 'II Chronicles',
'2chronicles' => 'II Chronicles',
'ezra' => 'Ezra',
'nehemiah' => 'Nehemiah',
'neh' => 'Nehemiah',
'esther' => 'Esther',
'ester' => 'Esther',
'esth' => 'Esther',
'job' => 'Job',
'psalms' => 'Psalms',
'psalm' => 'Psalms',
'psm' => 'Psalms',
'pss' => 'Psalms',
'ps' => 'Psalms',
'p' => 'Psalms',
'proverbs' => 'Proverbs',
'prov' => 'Proverbs',
'ecclesiastes' => 'Ecclesiastes',
'qoheleth' => 'Ecclesiastes',
'song of solomon' => 'Song of Solomon',
'song of songs' => 'Song of Solomon',
'solomon' => 'Song of Solomon',
'song' => 'Song of Solomon',
'sng' => 'Song of Solomon',
'sos' => 'Song of Solomon',
'isaiah' => 'Isaiah',
'isa' => 'Isaiah',
'isaiah' => 'Isaiah',
'jeremiah' => 'Jeremiah',
'jer' => 'Jeremiah',
'lamentations' => 'Lamentations',
'lam' => 'Lamentations',
'ezekiel' => 'Ezekiel',
'ezek' => 'Ezekiel',
'ezk' => 'Ezekiel',
'dan' => 'Daniel',
'daniel' => 'Daniel',
'hosea' => 'Hosea',
'hos' => 'Hosea',
'joel' => 'Joel',
'jol' => 'Joel',
'amos' => 'Amos',
'obadiah' => 'Obadiah',
'jonah' => 'Jonah',
'micah' => 'Micah',
'nahum' => 'Nahum',
'nam' => 'Nahum',
'habakkuk' => 'Habakkuk',
'hab' => 'Habakkuk',
'zephaniah' => 'Zephaniah',
'zeph' => 'Zephaniah',
'haggai' => 'Haggai',
'hag' => 'Haggai',
'zechariah' => 'Zechariah',
'zachariah' => 'Zechariah',
'malachi' => 'Malachi',
'mal' => 'Malachi',
'matthew' => 'Matthew',
'matt' => 'Matthew',
'ma' => 'Matthew',
'mt' => 'Matthew',
'mark' => 'Mark',
'mk' => 'Mark',
'mrk' => 'Mark',
'luke' => 'Luke',
'lk' => 'Luke',
'l' => 'Luke',
'john' => 'John',
'jhn' => 'John',
'jn' => 'John',
'jo' => 'John',
'j' => 'John',
'acts' => 'Acts',
'romans' => 'Romans',
'rom' => 'Romans',
'i corinthians' => 'I Corinthians',
'icorinthians' => 'I Corinthians',
'1 corinthians' => 'I Corinthians',
'1corinthians' => 'I Corinthians',
'1 cor' => 'I Corinthians',
'1cor' => 'I Corinthians',
'i c' => 'I Corinthians',
'ic' => 'I Corinthians',
'1 c' => 'I Corinthians',
'1c' => 'I Corinthians',
'ii corinthians' => 'II Corinthians',
'iicorinthians' => 'II Corinthians',
'2 corinthians' => 'II Corinthians',
'2corinthians' => 'II Corinthians',
'2 cor' => 'II Corinthians',
'2cor' => 'II Corinthians',
'ii c' => 'II Corinthians',
'iic' => 'II Corinthians',
'2 c' => 'II Corinthians',
'2c' => 'II Corinthians',
'galatians' => 'Galatians',
'gal' => 'Galatians',
'ephesians' => 'Ephesians',
'eph' => 'Ephesians',
'e' => 'Ephesians',
'philippians' => 'Philippians',
'philip' => 'Philippians',
'phil' => 'Philippians',
'php' => 'Philippians',
'colossians' => 'Colossians',
'col' => 'Colossians',
'c' => 'Colossians',
'1 thess' => 'I Thessalonians',
'1thess' => 'I Thessalonians',
'i thessalonians' => 'I Thessalonians',
'ithessalonians' => 'I Thessalonians',
'1 thessalonians' => 'I Thessalonians',
'1thessalonians' => 'I Thessalonians',
'ii thessalonians' => 'II Thessalonians',
'iithessalonians' => 'II Thessalonians',
'2 thessalonians' => 'II Thessalonians',
'2thessalonians' => 'II Thessalonians',
'2 thess' => 'II Thessalonians',
'2thess' => 'II Thessalonians',
'1tim' => 'I Timothy',
'1 tim' => 'I Timothy',
'i timothy' => 'I Timothy',
'itimothy' => 'I Timothy',
'1 timothy' => 'I Timothy',
'1timothy' => 'I Timothy',
'ii timothy' => 'II Timothy',
'iitimothy' => 'II Timothy',
'2 tim' => 'II Timothy',
'2tim' => 'II Timothy',
'2 timothy' => 'II Timothy',
'2timothy' => 'II Timothy',
'titus' => 'Titus',
'philemon' => 'Philemon',
'phlm' => 'Philemon',
'phm' => 'Philemon',
'hebrews' => 'Hebrews',
'heb' => 'Hebrews',
'h' => 'Hebrews',
'james' => 'James',
'jas' => 'James',
'i peter' => 'I Peter',
'ipeter' => 'I Peter',
'i ptr' => 'I Peter',
'iptr' => 'I Peter',
'1 peter' => 'I Peter',
'1peter' => 'I Peter',
'1 ptr' => 'I Peter',
'1ptr' => 'I Peter',
'ii peter' => 'II Peter',
'iipeter' => 'II Peter',
'ii ptr' => 'II Peter',
'iiptr' => 'II Peter',
'2 peter' => 'II Peter',
'2peter' => 'II Peter',
'2 ptr' => 'II Peter',
'2ptr' => 'II Peter',
'ii peter' => 'II Peter',
'i john' => 'I John',
'ijohn' => 'I John',
'1 john' => 'I John',
'1john' => 'I John',
'i jn' => 'I John',
'ijn' => 'I John',
'1 jn' => 'I John',
'1jn' => 'I John',
'ii john' => 'II John',
'iijohn' => 'II John',
'2 john' => 'II John',
'2john' => 'II John',
'ii jn' => 'II John',
'iijn' => 'II John',
'2 jn' => 'II John',
'2jn' => 'II John',
'iii john' => 'III John',
'iiijohn' => 'III John',
'3 john' => 'III John',
'3john' => 'III John',
'iii jn' => 'III John',
'iiijn' => 'III John',
'3 jn' => 'III John',
'3jn' => 'III John',
'jude' => 'Jude',
'revelation of john' => 'Revelation of John',
'revelations' => 'Revelation of John',
'revelation' => 'Revelation of John',
'rev' => 'Revelation of John'
);
var $chapters = array(
'Genesis' => array(31, 25, 24, 26, 32, 22, 24, 22, 29, 32,
32, 20, 18, 24, 21, 16, 27, 33, 38, 18,
34, 24, 20, 67, 34, 35, 46, 22, 35, 43,
55, 32, 20, 31, 29, 43, 36, 30, 23, 23,
57, 38, 34, 34, 28, 34, 31, 22, 33, 26),
'Exodus' => array(22, 25, 22, 31, 23, 30, 25, 32, 35, 29,
10, 51, 22, 31, 27, 36, 16, 27, 25, 26,
36, 31, 33, 18, 40, 37, 21, 43, 46, 38,
18, 35, 23, 35, 35, 38, 29, 31, 43, 38),
'Leviticus' => array(17, 16, 17, 35, 19, 30, 38, 36, 24, 20,
47, 8, 59, 57, 33, 34, 16, 30, 37, 27,
24, 33, 44, 23, 55, 46, 34),
'Numbers' => array(54, 34, 51, 49, 31, 27, 89, 26, 23, 36,
35, 16, 33, 45, 41, 50, 13, 32, 22, 29,
35, 41, 30, 25, 18, 65, 23, 31, 40, 16,
54, 42, 56, 29, 34, 13),
'Deuteronomy' => array(46, 37, 29, 49, 33, 25, 26, 20, 29, 22,
32, 32, 18, 29, 23, 22, 20, 22, 21, 20,
23, 30, 25, 22, 19, 19, 26, 68, 29, 20,
30, 52, 29, 12),
'Joshua' => array(18, 24, 17, 24, 15, 27, 26, 35, 27, 43,
23, 24, 33, 15, 63, 10, 18, 28, 51, 9,
45, 34, 16, 33),
'Judges' => array(36, 23, 31, 24, 31, 40, 25, 35, 57, 18,
40, 15, 25, 20, 20, 31, 13, 31, 30, 48,
25),
'Ruth' => array(22, 23, 18, 22),
'I Samuel' => array(28, 36, 21, 22, 12, 21, 17, 22, 27, 27,
15, 25, 23, 52, 35, 23, 58, 30, 24, 42,
15, 23, 29, 22, 44, 25, 12, 25, 11, 31,
13),
'II Samuel' => array(27, 32, 39, 12, 25, 23, 29, 18, 13, 19,
27, 31, 39, 33, 37, 23, 29, 33, 43, 26,
22, 51, 39, 25),
'I Kings' => array(53, 46, 28, 34, 18, 38, 51, 66, 28, 29,
43, 33, 34, 31, 34, 34, 24, 46, 21, 43,
29, 53),
'II Kings' => array(18, 25, 27, 44, 27, 33, 20, 29, 37, 36,
21, 21, 25, 29, 38, 20, 41, 37, 37, 21,
26, 20, 37, 20, 30),
'I Chronicles' => array(54, 55, 24, 43, 26, 81, 40, 40, 44, 14,
47, 40, 14, 17, 29, 43, 27, 17, 19, 8,
30, 19, 32, 31, 31, 32, 34, 21, 30),
'II Chronicles' => array(17, 18, 17, 22, 14, 42, 22, 18, 31, 19,
23, 16, 22, 15, 19, 14, 19, 34, 11, 37,
20, 12, 21, 27, 28, 23, 9, 27, 36, 27,
21, 33, 25, 33, 27, 23),
'Ezra' => array(11, 70, 13, 24, 17, 22, 28, 36, 15, 44),
'Nehemiah' => array(11, 20, 32, 23, 19, 19, 73, 18, 38, 39,
36, 47, 31),
'Esther' => array(22, 23, 15, 17, 14, 14, 10, 17, 32, 3),
'Job' => array(22, 13, 26, 21, 27, 30, 21, 22, 35, 22,
20, 25, 28, 22, 35, 22, 16, 21, 29, 29,
34, 30, 17<