Log in

View Full Version : array problem



motormichael12
12-30-2006, 12:55 AM
if i have...


<?php
function array_search_ci ($arr, $posted) {
foreach ($arr as $key => $value) {
$string =strtoupper(trim($arr[$key]));
$uppercase_it = strtoupper($posted);
if ($uppercase_it == $string) {
return $key;
}
}
}


$theircolor = $_POST['color'];
$theirtype = $_POST['type'];

$guncolor = array("black", "red", "blue", "green");
$guntype = array("shotgun", "pistol", "rifle", "musket");
array_search_ci("$guncolor", "$theircolor");
$gun=array_search_ci("$guncolor", "$theircolor");
if($_GET['act'] == "showtype") {
$showtype = $guntype[$gun];
echo $showtype;
}
?>
<form action="loginstart.php?act=showtype" method="POST">
color: <input name="color" type="text">
<INPUT TYPE="submit" VALUE="submit" NAME="submit">
</form>




when you submit the form it won't show the type of gun, it should show it depending on the color you type...

vpappan
12-30-2006, 04:01 AM
Hi,
i didnt understand what output you want.
tell me one example.
This code showing some error also.
Regards
Vijay

motormichael12
12-30-2006, 08:50 PM
it should output a type...
black = shotgun, red=pistol, blue=rifle, green=musket

when you submit form it should display a gun type according to position in arrays