I'm writing a simple php program that expect a text in the format book chapter:verse e.g. Matthew 6:2
So far, I've separated the book name from the number part by a space. I've printed them separately with an error message if the space isn't found and it won't process it. Here is my code.
<?php
if ($_GET) {
if ($_GET['citation']>"") {
print "Input detected<br />";
if (strpos($_GET['citation'], " ")){
$xname = explode(" ", $_GET['citation']);
print "Book: " . $xname[0]. "<br/>";
print "Text: " . $xname[1]. "<br/>";
}else{
print "There was no space<br />";
}
}
}
print "<form action=\"" . $_SERVER['PHP_SELF'] . "\" method=\"get\">";
print "Text:<input type=\"text\" name=\"citation\" value=\"" .
$_GET['citation'] .
"\" ><br />\n";
print "<input type=\"submit\" />";
print "</form>";
?>
Here is the challenging part. How do I check for a colon? If I don't put the colon, the program won't process it. How do I do that? Thanks for your help.