PDA

View Full Version : Array Question


AJW06
04-09-2007, 12:54 PM
$alpha = array("A", "a", "B","b", "C", "c", "D", "d", "E", "e", "F", "f", "G", "g", "H", "h");

if (in_array($_POST['textfield], $alpha) && !empty($_POST['textfield']) && !is_numeric($_POST['textfield'])) {
$Social = $_POST['textfield'];
} else {
$Social = NULL;
echo '<p><font color="red">Please Go Back Abd Re Enter Your Details</font></p>';
}


Is there a quicker way than right out my array in Cap and then non-cap.

rafiki
04-09-2007, 01:09 PM
f (in_array($_POST['textfield], $alpha) && !empty($_POST['textfield']) && !is_numeric($_POST['textfield'])) {
$Social = $_POST['textfield'];

notice the colour change? you forgot the ' after textfield in the first

f (in_array($_POST['textfield'], $alpha) && !empty($_POST['textfield']) && !is_numeric($_POST['textfield'])) {
$Social = $_POST['textfield'];

and im not sure if range() (http://www.php.net/function.range) works

$range = range('a', 'z');
$range .= range('A', 'Z');

you should check the link i provided though
/*edit*/ yes it does work with letters /*edit*/