Results 1 to 3 of 3

Thread: array problem

  1. #1
    Join Date
    Oct 2006
    Posts
    183
    Thanks
    0
    Thanked 11 Times in 11 Posts

    Default array problem

    if i have...

    PHP Code:
    <?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...

  2. #2
    Join Date
    Aug 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi,
    i didnt understand what output you want.
    tell me one example.
    This code showing some error also.
    Regards
    Vijay

  3. #3
    Join Date
    Oct 2006
    Posts
    183
    Thanks
    0
    Thanked 11 Times in 11 Posts

    Default

    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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •